Compare commits

...

6 Commits

Author SHA1 Message Date
Bigjango13 76a66a0ba5 Sneak in Level_setTileEntity
CI / Build (AMD64, Server) (push) Successful in 12m25s Details
CI / Build (AMD64, Client) (push) Successful in 12m41s Details
CI / Build (ARM64, Server) (push) Successful in 12m25s Details
CI / Build (ARM64, Client) (push) Successful in 12m56s Details
CI / Build (ARMHF, Server) (push) Successful in 8m51s Details
CI / Build (ARMHF, Client) (push) Successful in 11m57s Details
CI / Test (Client) (push) Successful in 14m36s Details
CI / Test (Server) (push) Successful in 12m32s Details
CI / Release (push) Has been skipped Details
CI / Build Example Mods (push) Failing after 7m21s Details
2024-03-18 21:02:01 -04:00
Bigjango13 a6ad1994de Remove left over check 2024-03-18 19:58:38 -04:00
Bigjango13 8de638eb1a Make chat history edits saved temporarily 2024-03-18 19:44:17 -04:00
Bigjango13 5e5088e3ef Move chat history into chat
- `get_death_message` is no longer static
- Fix ItemInHandRenderer_instance symbol
2024-03-10 22:46:34 -04:00
Bigjango13 a6e0cd8f13 Fix history editing bug
- Use the `get_<var>` pattern for chat's `history`.
- Make the Biome_map comment clearer
2024-03-09 13:01:52 -05:00
Bigjango13 3ff24c2a92 Add chat history
- More symbols too
- Made CUSTOM_VTABLE not static, for modders
2024-03-08 18:03:19 -05:00
30 changed files with 173 additions and 23 deletions

View File

@ -52,7 +52,7 @@ int reborn_is_server();
// Customize VTable
#define CUSTOM_VTABLE(name, parent) \
static void _setup_##name##_vtable(parent##_vtable *vtable); \
void _setup_##name##_vtable(parent##_vtable *vtable); \
static parent##_vtable *get_##name##_vtable() { \
static parent##_vtable *vtable = NULL; \
/* Allocate VTable */ \
@ -67,7 +67,7 @@ int reborn_is_server();
return vtable; \
} \
/* User-Defined Setup Code */ \
static void _setup_##name##_vtable(parent##_vtable *vtable)
void _setup_##name##_vtable(parent##_vtable *vtable)
#ifdef __cplusplus
}

View File

@ -18,6 +18,7 @@ struct TextInputBox {
void onClick(int x, int y);
bool clicked(int x, int y);
std::string getText();
void setText(std::string text);
bool isFocused();
void setMaxLength(int max_length);

View File

@ -3,4 +3,6 @@
#include <string>
#include <vector>
extern "C" {
void title_screen_load_splashes(std::vector<std::string> &splashes);
}

View File

@ -60,9 +60,9 @@ void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) {
RakNetInstance *rak_net_instance = minecraft->rak_net_instance;
if (rak_net_instance->vtable->isServer(rak_net_instance)) {
// Hosting Multiplayer
char *message = packet->message;
const char *message = packet->message.c_str();
ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) minecraft->network_handler;
chat_send_message(server_side_network_handler, Strings_default_username, message);
chat_send_message(server_side_network_handler, Strings_default_username, (char *) message);
} else {
// Client
rak_net_instance->vtable->send(rak_net_instance, (Packet *) packet);
@ -82,8 +82,8 @@ static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetwo
Player *player = ServerSideNetworkHandler_getPlayer(server_side_network_handler, rak_net_guid);
if (player != NULL) {
const char *username = player->username.c_str();
char *message = chat_packet->message;
chat_send_message(server_side_network_handler, (char *) username, message);
const char *message = chat_packet->message.c_str();
chat_send_message(server_side_network_handler, (char *) username, (char *) message);
}
}

View File

@ -10,15 +10,22 @@
#include <mods/misc/misc.h>
#include <mods/touch/touch.h>
static std::vector<std::string> &get_history() {
static std::vector<std::string> history = {};
return history;
}
// Structure
struct ChatScreen {
TextInputScreen super;
TextInputBox *chat;
Button *send;
int history_pos;
};
CUSTOM_VTABLE(chat_screen, Screen) {
TextInputScreen::setup(vtable);
// Init
static std::vector<std::string> local_history = {};
static Screen_init_t original_init = vtable->init;
vtable->init = [](Screen *super) {
original_init(super);
@ -28,6 +35,9 @@ CUSTOM_VTABLE(chat_screen, Screen) {
self->super.m_textInputs->push_back(self->chat);
self->chat->init(super->font);
self->chat->setFocused(true);
self->history_pos = get_history().size();
local_history = get_history();
local_history.push_back("");
// Determine Max Length
std::string prefix = _chat_get_prefix(Strings_default_username);
int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length();
@ -76,11 +86,33 @@ CUSTOM_VTABLE(chat_screen, Screen) {
vtable->keyPressed = [](Screen *super, int key) {
// Handle Enter
ChatScreen *self = (ChatScreen *) super;
if (key == 0x0d && self->chat->isFocused()) {
if (self->chat->getText().length() > 0) {
_chat_queue_message(self->chat->getText().c_str());
if (self->chat->isFocused()) {
if (key == 0x0d) {
if (self->chat->getText().length() > 0) {
std::string text = self->chat->getText();
if (get_history().size() == 0 || text != get_history().back()) {
get_history().push_back(text);
}
_chat_queue_message(text.c_str());
}
Minecraft_setScreen(super->minecraft, NULL);
} else if (key == 0x26) {
// Up
local_history.at(self->history_pos) = self->chat->getText();
// Change
self->history_pos -= 1;
if (self->history_pos < 0) self->history_pos = local_history.size() - 1;
self->chat->setText(local_history.at(self->history_pos));
return;
} else if (key == 0x28) {
// Down
local_history.at(self->history_pos) = self->chat->getText();
// Change
self->history_pos += 1;
if (self->history_pos > int(local_history.size()) - 1) self->history_pos = 0;
self->chat->setText(local_history.at(self->history_pos));
return;
}
Minecraft_setScreen(super->minecraft, NULL);
}
// Call Original Method
original_keyPressed(super, key);

View File

@ -8,7 +8,7 @@
// Death Messages
static const char *monster_names[] = {"Zombie", "Creeper", "Skeleton", "Spider", "Zombie Pigman"};
static std::string get_death_message(Player *player, Entity *cause, bool was_shot = false) {
std::string get_death_message(Player *player, Entity *cause, bool was_shot = false) {
// Prepare Death Message
std::string message = player->username;
if (cause) {

View File

@ -285,6 +285,11 @@ std::string TextInputBox::getText() {
return m_text;
}
void TextInputBox::setText(std::string str) {
m_text = str;
m_insertHead = int(m_text.size());
}
bool TextInputBox::isFocused() {
return m_bFocused;
}

View File

@ -66,6 +66,7 @@ set(SRC
src/level/container/Container.def
src/level/container/ContainerMenu.def
src/level/container/Inventory.def
src/level/feature/Feature.def
src/level/feature/LargeFeature.def
src/level/feature/LargeCaveFeature.def
src/level/Material.def
@ -97,6 +98,7 @@ set(SRC
src/item/ArmorItem.def
src/item/TileItem.def
src/item/FoodItem.def
src/item/DiggerItem.def
src/api/OffsetPosTranslator.def
src/api/CommandServer.def
src/api/ConnectedClient.def

View File

@ -1,5 +1,6 @@
virtual-method void remove() = 0x10;
virtual-method void tick() = 0x34;
virtual-method float getBrightness(float param_1) = 0x64;
virtual-method bool interact(Player *with) = 0x6c;
virtual-method void playerTouch(Player *player) = 0x70;
virtual-method bool isPlayer() = 0x94;
@ -36,4 +37,6 @@ property float height_offset = 0x68;
property int fire_timer = 0xa0;
property int renderer_id = 0xa8;
property bool on_ground = 0xb2;
property bool pending_removal = 0xb8;
property bool freeze_physics = 0xb9;
property float fall_distance = 0xac;

View File

@ -3,3 +3,5 @@ constructor () = 0x6096c;
method void assign(uchar entity_id, EntityRenderer *renderer) = 0x6094c;
method void render(Entity *entity, float x, float y, float z, float rot, float unknown) = 0x60674;
static-method EntityRenderDispatcher *getInstance() = 0x60e90;
property ItemInHandRenderer *item_renderer = 0x0;

View File

@ -1,3 +1,4 @@
method void tick(int tick, int max_ticks) = 0x495bc;
method void render(float param_1) = 0x4a338;
method void setupCamera(float param_1, int param_2) = 0x489f8;

View File

@ -4,7 +4,7 @@ method void tickInput() = 0x15ffc;
method void setIsCreativeMode(int is_creative) = 0x16ec4;
method int isTouchscreen() = 0x1639c;
method void setScreen(Screen *screen) = 0x15d6c;
method void tick(int param_1, int param_2) = 0x16934;
method void tick(int tick, int max_ticks) = 0x16934;
method void hostMultiplayer(int port) = 0x16664;
method char *getProgressMessage() = 0x16e58;
method uint isLevelGenerated() = 0x16e6c;
@ -27,21 +27,24 @@ property int screen_width = 0x20;
property int screen_height = 0x24;
property Options options = 0x3c;
property LevelRenderer *levelrenderer = 0x150;
property GameRenderer *gamerenderer = 0x154;
property GameMode *game_mode = 0x160;
property Textures *textures = 0x164;
property ScreenChooser screen_chooser = 0x168;
property Font *font = 0x16c;
property RakNetInstance *rak_net_instance = 0x170;
property NetEventCallback *network_handler = 0x174;
property Level *level = 0x188;
property LocalPlayer *player = 0x18c;
property Mob *camera = 0x194;
property Gui gui = 0x198;
property LocalPlayer *player = 0x18c;
property Screen *screen = 0xc10;
property HitResult hit_result = 0xc38;
property int progress = 0xc60;
property int ticks_per_update = 0xc70;
property bool is_creative_mode = 0xcb5;
property PerfRenderer *perf_renderer = 0xcbc;
property CommandServer *command_server = 0xcc0;
property Font *font = 0x16c;
property ScreenChooser screen_chooser = 0x168;
// Smooth Lighting
static-property bool useAmbientOcclusion = 0x136b90;

View File

@ -0,0 +1,3 @@
extends Item;
property float speed = 0x24;

View File

@ -4,4 +4,4 @@ property ItemInstance item = 0xc;
property Minecraft *mc = 0x18;
method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824;
method void render(float param_1) = 0x4bfcc;
method void render(float param_1) = 0x4bfcc;

View File

@ -1,2 +1,20 @@
vtable 0x110180;
vtable-size 0x24;
static-method void initBiomes() = 0xae320;
static-method void recalc() = 0xae010;
static-method Biome *_getBiome(float temp, float humidity) = 0xadf04;
virtual-method Feature *getTreeFeature(Random *random) = 0x8;
virtual-method Feature *getGrassFeature(Random *random) = 0xc;
virtual-method float adjustScale(float scale) = 0x10;
virtual-method float adjustDepth(float depth) = 0x14;
virtual-method uint getSkyColor(float temp) = 0x18;
//virtual-method ??? *getMobs(MobCategory *category) = 0x1c;
virtual-method float getCreatureProbability() = 0x20;
property int color = 0x2c;
property int leaf_color = 0x34;
// This is a Biome*[64x64], temp x humidity
static-property-array Biome *map = 0x17c970;

View File

@ -3,25 +3,46 @@ extends LevelSource;
vtable 0x10fcf0;
method void saveLevelData() = 0xa2e94;
method void setTile(int x, int y, int z, int id) = 0xa3904;
method void setTileAndData(int x, int y, int z, int id, int data) = 0xa38b4;
method void setTileAndDataNoUpdate(int x, int y, int z, int id, int data) = 0xa33d0;
method HitResult clip(uchar *param_1, uchar *param_2, bool clip_liquids, bool param_3) = 0xa3db0;
// clip_liquids and clip_hitboxes default to true
// If clip_hitboxes is true it will ignore blocks that have their getAABB return NULL
method HitResult clip(uchar *param_1, uchar *param_2, bool clip_liquids, bool clip_hitboxes) = 0xa3db0;
// Valid particles are crit, flame, lava, smoke, largesmoke, reddust, snowballpoof, and explode
// There is also bubble which only works under water and ironcrack which will crash the game
method void addParticle(std::string *particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) = 0xa449c;
method Entity *getEntity(int id) = 0xa45a4;
method bool addEntity(Entity *entity) = 0xa7cbc;
method int getBrightness2(LightLayer *layer, int x, int y, int z) = 0xa3c70;
method int getRawBrightness(int x, int y, int z) = 0xa3b70;
// See mods/src/sound/repository.cpp for a list of sounds
method void playSound(Entity *entity, std::string *name, float volume, float pitch) = 0xa42a8;
// Searches aabb for entities, ignores the entity "ignore", overwrites the same vector each time
method std::vector<Entity*> *getEntities(Entity *ignore, AABB *aabb) = 0xa5a4c;
// Searches aabb for entities of type type_id, adds then to buff, returns the number of entities added
method int getEntitiesOfType(int type_id, AABB *aabb, std::vector<Entity*> *buff) = 0xa612c;
// Searches aabb for entities of base type base_type, adds then to buff, returns the number of entities added
method int getEntitiesOfClass(int base_type, AABB *aabb, std::vector<Entity*> *buff) = 0xa6240;
// This will implicitly make the tile entity if the tile at x, y, z doesn't have one and is an EntityTile
method TileEntity *getTileEntity(int x, int y, int z) = 0xa55d4;
method void setTileEntity(int x, int y, int z, TileEntity *tileEntity) = 0xa7b58;
method void removeTileEntity(int x, int y, int z) = 0xa7aac;
method void animateTick(int x, int y, int z) = 0xa5920;
// Called by trapdoors, doors, and tnt
method bool hasNeighborSignal(int x, int y, int z) = 0xa5f08;
// Called by hasNeighborSignal
method bool getSignal(int x, int y, int z, int direction) = 0xa5e6c;
// Called by getSignal
method bool hasDirectSignal(int x, int y, int z) = 0xa5d88;
// Called by hasDirectSignal
method bool getDirectSignal(int x, int y, int z, int direction) = 0xa5d2c;
virtual-method void tick() = 0x28;
virtual-method void updateSleepingPlayerList() = 0x2c;
virtual-method ChunkCache *createChunkSource() = 0x30;
property bool done_generating = 0x12;
property std::vector<Entity *> entities = 0x20;
property std::vector<TileEntity *> tileentities = 0x50;
property std::vector<Player *> players = 0x60;

View File

@ -1,3 +1,4 @@
method void tick() = 0x4da1c;
method void render(Mob *mob, int param_1, float delta) = 0x4f710;
method void renderDebug(AABB *aabb, float delta) = 0x4d310;
method void generateSky() = 0x4d0d4;

View File

@ -1,7 +1,8 @@
virtual-method bool isSolid() = 0x8;
// Globals
static-property Material *dirt = 0x180a94;
static-property Material *dirt = 0x180a94;
static-property Material *stone = 0x180a9c;
static-property Material *metal = 0x180aa0;
static-property Material *plant = 0x180ab0;
static-property Material *glass = 0x180acc;

View File

@ -5,4 +5,5 @@ vtable 0x110598;
method void buildSurface(int chunk_x, int chunk_y, uchar *chunk_data, Biome **biomes) = 0xb32ec;
property LargeCaveFeature cave_feature = 0x8;
property Random random = 0x19f8;
property Level *level = 0x72c8;

View File

@ -1,5 +1,6 @@
extends Level;
vtable 0x109da0;
size 0xb80;
constructor (uchar *storage, uchar *name, LevelSettings *settings, int param_4, Dimension *dimension) = 0x7692c;

View File

@ -6,5 +6,7 @@ method ItemInstance *getSelected() = 0x8d134;
// It's just FillingContainer_linkSlot with selectedSlot as linked_slot
method bool moveToSelectedSlot(int unlinked_slot, bool push_aside) = 0x8d148;
method void setupDefault() = 0x8d164;
method void clearInventoryWithDefault() = 0x8e7c8;
method void clearInventory() = 0x92b84;
property int selectedSlot = 0x28;

View File

@ -0,0 +1,9 @@
constructor () = 0xb64a0;
vtable 0x10e530;
vtable-size 0x10;
// Pure virtual
virtual-method bool place(Level *level, Random *random, int x, int y, int z) = 0x8;
// Not sure about args, it doesn't seem to be used at all
virtual-method void init(float x, float y, float z) = 0xc;

View File

@ -5,6 +5,9 @@ size 0x24;
constructor (std::string name) = 0x69740;
method bool getBoolean(std::string *name) = 0xd1b28;
method char getByte(std::string *name) = 0x7f00c;
method void putByte(std::string *name, char i) = 0x7d6d0;
method short getShort(std::string *name) = 0x459c0;
method void putShort(std::string *name, short i) = 0x7d60c;
method bool contains(std::string *name, int type) = 0x7d130;
method void put(std::string *name, Tag *tag) = 0x6a040;

View File

@ -5,3 +5,4 @@ static-method float sin(float x) = 0x7775c;
static-method float cos(float x) = 0x77728;
static-method float abs(float x) = 0x7781c;
static-method float min(float a, float b) = 0x7782c;
static-method float invSqrt(float a) = 0x776d4;

View File

@ -4,5 +4,6 @@ method void colorABGR(int color) = 0x52b54;
method void color(int r, int g, int b, int a) = 0x52a48;
method void vertex(float x, float y, float z) = 052bc0;
method void vertexUV(float x, float y, float z, float u, float v) = 0x52d40;
method void addOffset(float x, float y, float z) = 0x52d90;
static-property Tesselator instance = 0x137538;

View File

@ -2,4 +2,4 @@ extends Packet;
vtable 0x108a98;
property char *message = 0xc;
property std::string message = 0xc;

View File

@ -1,5 +1,6 @@
constructor () = 0x6fc18;
size 0x10;
size 0x8;
vtable 0x1024d8;
vtable-size 0x14;

View File

@ -4,4 +4,5 @@ vtable 0x111348;
vtable-size 0x108;
size 0x5c;
// Pure virtual
virtual-method TileEntity *newTileEntity() = 0x104;

View File

@ -19,15 +19,32 @@ virtual-method int getTexture2(int face, int data) = 0x2c;
virtual-method int getTexture3(LevelSource *level, int x, int y, int z, int face) = 0x30;
virtual-method AABB *getAABB(Level *level, int x, int y, int z) = 0x34;
virtual-method bool isSolidRender() = 0x40;
virtual-method bool mayPlace(Level *level, int x, int y, int z, uchar face) = 0x4c;
virtual-method bool mayPlace2(Level *level, int x, int y, int z) = 0x50;
virtual-method void tick(Level *level, int x, int y, int z) = 0x58;
virtual-method void neighborChanged(Level *level, int x, int y, int z, int neighborId) = 0x64;
virtual-method void onPlace(Level *level, int x, int y, int z) = 0x68;
virtual-method void onRemove(Level *level, int x, int y, int z) = 0x6c;
// Resource is the dropped item
virtual-method int getResource(int data, Random *random) = 0x70;
virtual-method int getResourceCount(Random *random) = 0x74;
// Returns 1 (default, not transparent), 2 (transparent when the texture is, like bushes), or 3 (semi-transparent, like water)
virtual-method int getRenderLayer() = 0x94;
virtual-method int use(Level *level, int x, int y, int z, Player *player) = 0x98;
virtual-method void setPlacedBy(Level *level, int x, int y, int z, Mob *placer) = 0xa8;
virtual-method void handleEntityInside(Level *level, int x, int y, int z, Entity *entity, Vec3 *speed) = 0xb4;
// Note that this may be ignored depending on the value of getRenderShape
virtual-method int getColor(LevelSource *level_source, int x, int y, int z) = 0xb8;
// This doesn't mean that it *is* producing a signal, rather that it might be
// Called by trapdoors, doors, and tnt. Never overridden (always returns false)
virtual-method bool isSignalSource() = 0xbc;
// Doesn't seem to be used, but it's hard to tell with virtual methods
// Yes, this IS a bool and not a char.
virtual-method bool getSignal(LevelSource *level, int x, int y, int z) = 0xc0;
// Called at the end of Level_getSignal
virtual-method bool getSignal2(LevelSource *level, int x, int y, int z, int direction) = 0xc4;
// Called by Level_hasDirectSignal
virtual-method bool getDirectSignal(Level *level, int x, int y, int z, int direction) = 0xc8;
virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc;
virtual-method std::string getDescriptionId() = 0xdc;
virtual-method Tile *setDescriptionId(std::string *description_id) = 0xe0;
@ -38,6 +55,14 @@ virtual-method Tile *setDestroyTime(float destroy_time) = 0xf8;
property int texture = 0x4;
property int id = 0x8;
property float x1 = 0xc;
property float y1 = 0x10;
property float z1 = 0x14;
property float x2 = 0x18;
property float y2 = 0x1c;
property float z2 = 0x20;
property float destroyTime = 0x34;
property float explodeable = 0x38;
property int category = 0x3c;
property AABB aabb = 0x40;
@ -47,6 +72,8 @@ static-property-array float lightEmission = 0x181214;
static-property-array bool isEntityTile = 0x181f20;
// Tiles
static-property Tile *grass = 0x181b14;
static-property Tile *leaves = 0x18120c;
static-property Tile *chest = 0x181d60;
static-property Tile *water = 0x181b3c;
static-property Tile *lava = 0x181cc8;
@ -66,10 +93,10 @@ static-property Tile *stoneSlab = 0x181b44;
static-property Tile *fire = 0x181de0;
// "Carried" Tiles
static-property Tile *leaves = 0x18120c;
static-property Tile *leaves_carried = 0x181dd8;
static-property Tile *grass = 0x181b14;
static-property Tile *grass_carried = 0x181dd4;
// Sounds
static-property Tile_SoundType SOUND_STONE = 0x181c80;
static-property Tile_SoundType SOUND_WOOD = 0x181cb4;
static-property Tile_SoundType SOUND_GRASS = 0x181c94;

View File

@ -1,4 +1,12 @@
size 0xb8;
constructor (Minecraft *minecraft, LevelSource *level) = 0x53e58;
static-method bool canRender(int shape) = 0x5accc;
method bool tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30;
method bool tesselateInWorld(Tile *tile, int x, int y, int z) = 0x5e80c;
method void renderGuiTile(Tile *tile, int aux) = 0x5ad0c;
method void renderTile(Tile *tile, int data) = 0x5dcb0;
property Level *level = 0x0;
property LevelSource *level = 0x0;