From 6ac808919f9461b6e1662c2d91c69dddd199fd32 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 12 Feb 2024 02:29:35 -0500 Subject: [PATCH] More symbols! Mostly tile entity stuff --- mods/src/misc/misc.c | 2 +- mods/src/sign/sign.cpp | 2 +- symbols/CMakeLists.txt | 10 ++++++- symbols/src/entity/EntityRenderer.def | 3 ++ symbols/src/entity/animal/Animal.def | 4 +++ symbols/src/item/ItemInHandRenderer.def | 2 ++ symbols/src/item/ItemInstance.def | 4 +++ symbols/src/level/Level.def | 3 ++ symbols/src/misc/CompoundTag.def | 10 +++++++ symbols/src/misc/Tag.def | 1 + symbols/src/network/RakNetInstance.def | 1 + symbols/src/tile/EntityTile.def | 7 +++++ symbols/src/tile/Tile.def | 8 ++--- symbols/src/tile/entity/TileEntity.def | 29 ++++++++++++++++--- symbols/src/tile/entity/TileEntityFactory.def | 1 + .../entity/TileEntityRenderDispatcher.def | 4 +++ .../src/tile/entity/TileEntityRenderer.def | 11 +++++++ 17 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 symbols/src/misc/CompoundTag.def create mode 100644 symbols/src/misc/Tag.def create mode 100644 symbols/src/tile/EntityTile.def create mode 100644 symbols/src/tile/entity/TileEntityFactory.def create mode 100644 symbols/src/tile/entity/TileEntityRenderDispatcher.def create mode 100644 symbols/src/tile/entity/TileEntityRenderer.def diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 46570de494..f1a8b97efd 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -468,7 +468,7 @@ static Entity *PathfinderMob_findAttackTarget_injection(PathfinderMob *mob) { // Call Original Method Entity *target = mob->vtable->findAttackTarget(mob); - // Check if hostile + // Only modify the AI of monsters if (mob->vtable->getCreatureBaseType(mob) != 1) { return target; } diff --git a/mods/src/sign/sign.cpp b/mods/src/sign/sign.cpp index eeb61ffbb6..c667a07730 100644 --- a/mods/src/sign/sign.cpp +++ b/mods/src/sign/sign.cpp @@ -31,7 +31,7 @@ static int32_t sdl_key_to_minecraft_key_injection(int32_t sdl_key) { // Open Sign Screen static void LocalPlayer_openTextEdit_injection(LocalPlayer *local_player, TileEntity *sign) { - if (sign->id == 4) { + if (sign->type == 4) { Minecraft *minecraft = local_player->minecraft; TextEditScreen *screen = alloc_TextEditScreen(); ALLOC_CHECK(screen); diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 4a842aa982..6c0071d736 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -133,15 +133,19 @@ set(SRC src/tile/Tile.def src/tile/LiquidTile.def src/tile/TallGrass.def - src/tile/entity/ChestTileEntity.def src/tile/entity/TileEntity.def + src/tile/entity/ChestTileEntity.def src/tile/entity/FurnaceTileEntity.def src/tile/entity/SignTileEntity.def + src/tile/entity/TileEntityFactory.def + src/tile/entity/TileEntityRenderer.def + src/tile/entity/TileEntityRenderDispatcher.def src/tile/StemTile.def src/tile/Tile_SoundType.def src/tile/TileRenderer.def src/tile/GrassTile.def src/tile/HeavyTile.def + src/tile/EntityTile.def src/misc/Strings.def src/misc/I18n.def src/misc/SimpleFoodData.def @@ -160,6 +164,8 @@ set(SRC src/misc/Random.def src/misc/Mth.def src/misc/Util.def + src/misc/Tag.def + src/misc/CompoundTag.def src/input/IMoveInput.def src/input/IBuildInput.def src/input/MouseBuildInput.def @@ -225,3 +231,5 @@ install(TARGETS symbols DESTINATION "${MCPI_LIB_DIR}") # SDK install(TARGETS symbols EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") install(DIRECTORY "${INCLUDE_OUTPUT_DIR}/" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/symbols") + +target_compile_options(symbols PUBLIC $<$:-Wno-invalid-offsetof>) diff --git a/symbols/src/entity/EntityRenderer.def b/symbols/src/entity/EntityRenderer.def index 6164818294..6b4880befd 100644 --- a/symbols/src/entity/EntityRenderer.def +++ b/symbols/src/entity/EntityRenderer.def @@ -1 +1,4 @@ virtual-method void render(Entity *entity, float param_2, float param_3, float param_4, float param_5, float param_6) = 0x8; + +// Can be called without an EntityRenderer, just do EntityRenderer_bindTexture(NULL, &file); +method void bindTexture(std::string *file) = 0x62540; diff --git a/symbols/src/entity/animal/Animal.def b/symbols/src/entity/animal/Animal.def index bab8e39764..3e942ffd0f 100644 --- a/symbols/src/entity/animal/Animal.def +++ b/symbols/src/entity/animal/Animal.def @@ -1,3 +1,7 @@ extends AgableMob; vtable 0x10b588; + +// This int seems to be unused, and changing it doesn't effect anything +// I've called it love_timer because it matches where the love timer is on older java +property int love_timer = 0xc00; diff --git a/symbols/src/item/ItemInHandRenderer.def b/symbols/src/item/ItemInHandRenderer.def index ac3f3ed723..aace45ef08 100644 --- a/symbols/src/item/ItemInHandRenderer.def +++ b/symbols/src/item/ItemInHandRenderer.def @@ -5,3 +5,5 @@ property Minecraft *mc = 0x18; method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824; method void render(float param_1) = 0x4bfcc; + +static-property ItemInHandRenderer **instance = 0x137bc0; diff --git a/symbols/src/item/ItemInstance.def b/symbols/src/item/ItemInstance.def index 6a07e7b68d..6726ce1a76 100644 --- a/symbols/src/item/ItemInstance.def +++ b/symbols/src/item/ItemInstance.def @@ -5,7 +5,11 @@ constructor tile(Tile *item) = 0x998e4; constructor tile_extra(Tile *item, int count, int auxiliary) = 0x99918; constructor item_extra(Item *item, int count, int auxiliary) = 0x99960; +static-method ItemInstance *fromTag(CompoundTag *tag) = 0x9a124; + +method void save(CompoundTag *tag) = 0x9a31c; method int getMaxStackSize() = 0x99ac8; +method bool isNull() = 0x999b0; property int count = 0x0; property int id = 0x4; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index d9548ad9cd..14b50f97cc 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -15,10 +15,13 @@ method void playSound(Entity *entity, std::string *name, float volume, float pit method int getEntitiesOfType(int type_id, AABB *aabb, std::vector *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 *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; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; virtual-method ChunkCache *createChunkSource() = 0x30; property std::vector entities = 0x20; +property std::vector tileentities = 0x50; property std::vector players = 0x60; diff --git a/symbols/src/misc/CompoundTag.def b/symbols/src/misc/CompoundTag.def new file mode 100644 index 0000000000..bd3a4652d1 --- /dev/null +++ b/symbols/src/misc/CompoundTag.def @@ -0,0 +1,10 @@ +extends Tag; + +vtable-size 0x34; +size 0x24; +constructor (std::string name) = 0x69740; + +method bool getBoolean(std::string *name) = 0xd1b28; +method short getShort(std::string *name) = 0x459c0; +method bool contains(std::string *name, int type) = 0x7d130; +method void put(std::string *name, Tag *tag) = 0x6a040; diff --git a/symbols/src/misc/Tag.def b/symbols/src/misc/Tag.def new file mode 100644 index 0000000000..e12be66380 --- /dev/null +++ b/symbols/src/misc/Tag.def @@ -0,0 +1 @@ +constructor () = 0x684e0; diff --git a/symbols/src/network/RakNetInstance.def b/symbols/src/network/RakNetInstance.def index 497cbfff9d..09ec176c8e 100644 --- a/symbols/src/network/RakNetInstance.def +++ b/symbols/src/network/RakNetInstance.def @@ -2,6 +2,7 @@ vtable 0x109ae8; constructor () = 0x73b20; +virtual-method void sendTo(RakNet_RakNetGUID *guid, Packet *packet) = 0x3c; virtual-method void send(Packet *packet) = 0x38; virtual-method uint isServer() = 0x48; virtual-method void pingForHosts(int base_port) = 0x14; diff --git a/symbols/src/tile/EntityTile.def b/symbols/src/tile/EntityTile.def new file mode 100644 index 0000000000..2d0fec233f --- /dev/null +++ b/symbols/src/tile/EntityTile.def @@ -0,0 +1,7 @@ +extends Tile; + +vtable 0x111348; +vtable-size 0x108; +size 0x5c; + +virtual-method TileEntity *newTileEntity() = 0x104; diff --git a/symbols/src/tile/Tile.def b/symbols/src/tile/Tile.def index 60aacc2492..62270ae81c 100644 --- a/symbols/src/tile/Tile.def +++ b/symbols/src/tile/Tile.def @@ -26,6 +26,7 @@ virtual-method void onRemove(Level *level, int x, int y, int z) = 0x6c; 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; virtual-method int getColor(LevelSource *level_source, int x, int y, int z) = 0xb8; virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc; virtual-method std::string getDescriptionId() = 0xdc; @@ -40,8 +41,10 @@ property int id = 0x8; property int category = 0x3c; property AABB aabb = 0x40; -// Globals +// Globals, all of theses are 256 elements long static-property-array Tile *tiles = 0x180e08; +static-property-array float lightEmission = 0x181214; +static-property-array bool isEntityTile = 0x181f20; // Tiles static-property Tile *chest = 0x181d60; @@ -70,6 +73,3 @@ static-property Tile *grass_carried = 0x181dd4; // Sounds static-property Tile_SoundType SOUND_STONE = 0x181c80; - -// Light -static-property float *lightEmission = 0x181214; diff --git a/symbols/src/tile/entity/TileEntity.def b/symbols/src/tile/entity/TileEntity.def index 37f81ccca0..68c0064119 100644 --- a/symbols/src/tile/entity/TileEntity.def +++ b/symbols/src/tile/entity/TileEntity.def @@ -1,5 +1,26 @@ -property int id = 0x18; -property int renderer_id = 0x24; +size 0x30; +vtable-size 0x28; +vtable 0x115d78; +constructor (int type) = 0xd2308; + +static-method void setId(int id, std::string *name) = 0xd26fc; +static-method void initTileEntities() = 0xd2834; + +virtual-method bool shouldSave() = 0x8; +virtual-method void load(CompoundTag *tag) = 0xc; +virtual-method bool save(CompoundTag *tag) = 0x10; +virtual-method void tick() = 0x14; + +property Level *level = 0x4; +property int x = 0x8; +property int y = 0xc; +property int z = 0x10; +property int tile_data = 0x14; +property int type = 0x18; +property int id = 0x1c; property bool is_client = 0x20; -property int tile = 0xd0; -property int lifetime = 0xd8; +property int renderer_id = 0x24; +property Tile *tile = 0x28; +property bool pending_removal = 0x2c; +//property int tile = 0xd0; +//property int lifetime = 0xd8; diff --git a/symbols/src/tile/entity/TileEntityFactory.def b/symbols/src/tile/entity/TileEntityFactory.def new file mode 100644 index 0000000000..dfa1b28e1c --- /dev/null +++ b/symbols/src/tile/entity/TileEntityFactory.def @@ -0,0 +1 @@ +static-method TileEntity *createTileEntity(int type) = 0xd226c; diff --git a/symbols/src/tile/entity/TileEntityRenderDispatcher.def b/symbols/src/tile/entity/TileEntityRenderDispatcher.def new file mode 100644 index 0000000000..92d67cd1b1 --- /dev/null +++ b/symbols/src/tile/entity/TileEntityRenderDispatcher.def @@ -0,0 +1,4 @@ +constructor () = 0x66f18; + +property Level *level = 0x4; +property std::map renderer_map = 0x24; diff --git a/symbols/src/tile/entity/TileEntityRenderer.def b/symbols/src/tile/entity/TileEntityRenderer.def new file mode 100644 index 0000000000..57434d7422 --- /dev/null +++ b/symbols/src/tile/entity/TileEntityRenderer.def @@ -0,0 +1,11 @@ +size 0x8; + +vtable 0x1081c0; +vtable-size 0x14; +constructor () = 0x67620; + +virtual-method void render(TileEntity *tileentity, float x, float y, float z, float unknown) = 0x8; +virtual-method void onGraphicsReset() = 0xc; +virtual-method void onNewLevel(Level *level) = 0x10; + +property TileEntityRenderDispatcher *tileEntityRenderDispatcher = 0x4;