From 3bd9261a27857f2b5c0601b98bbe372546f7f36a Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 8 Feb 2024 17:30:41 -0500 Subject: [PATCH 1/7] More symbols and clean up "Disable Hostile AI In Creative Mode" --- mods/src/misc/misc.c | 21 +++++++++++---------- symbols/CMakeLists.txt | 10 +++++++++- symbols/src/entity/Entity.def | 5 ++--- symbols/src/entity/ItemEntity.def | 6 +++++- symbols/src/entity/Mob.def | 1 + symbols/src/entity/PathfinderMob.def | 5 +++++ symbols/src/entity/animal/Animal.def | 2 ++ symbols/src/entity/animal/Chicken.def | 4 ++++ symbols/src/entity/animal/Cow.def | 1 + symbols/src/entity/animal/Pig.def | 4 ++++ symbols/src/entity/{ => animal}/Sheep.def | 3 +++ symbols/src/entity/monster/Creeper.def | 4 ++++ symbols/src/entity/monster/Monster.def | 4 ++++ symbols/src/entity/monster/PigZombie.def | 4 ++++ symbols/src/entity/monster/Skeleton.def | 4 ++++ symbols/src/entity/monster/Spider.def | 4 ++++ symbols/src/entity/monster/Zombie.def | 4 ++++ symbols/src/item/Item.def | 2 ++ symbols/src/level/Level.def | 4 ++++ 19 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 symbols/src/entity/animal/Chicken.def create mode 100644 symbols/src/entity/animal/Pig.def rename symbols/src/entity/{ => animal}/Sheep.def (51%) create mode 100644 symbols/src/entity/monster/Creeper.def create mode 100644 symbols/src/entity/monster/Monster.def create mode 100644 symbols/src/entity/monster/PigZombie.def create mode 100644 symbols/src/entity/monster/Skeleton.def create mode 100644 symbols/src/entity/monster/Spider.def create mode 100644 symbols/src/entity/monster/Zombie.def diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index aac9da4..5d66620 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -464,21 +464,22 @@ static int32_t Tile_getColor_injection() { } // Disable Hostile AI In Creative Mode -#define has_vtable(obj, type) (((void *) obj->vtable) == type##_vtable_base) static Entity *PathfinderMob_findAttackTarget_injection(PathfinderMob *mob) { // Call Original Method Entity *target = mob->vtable->findAttackTarget(mob); + // Check if hostile + if (mob->vtable->getCreatureBaseType(mob) != 1) { + return target; + } + // Check If Creative Mode - if (target != NULL) { - bool is_player = has_vtable(target, Player) || has_vtable(target, LocalPlayer) || has_vtable(target, ServerPlayer) || has_vtable(target, RemotePlayer); - if (is_player) { - Player *player = (Player *) target; - Inventory *inventory = player->inventory; - bool is_creative = inventory->is_creative; - if (is_creative) { - target = NULL; - } + if (target != NULL && target->vtable->isPlayer(target)) { + Player *player = (Player *) target; + Inventory *inventory = player->inventory; + bool is_creative = inventory->is_creative; + if (is_creative) { + target = NULL; } } diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 93360c2..4a842aa 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -33,7 +33,6 @@ set(SRC src/entity/CameraEntity.def src/entity/EntityRenderer.def src/entity/ItemSpriteRenderer.def - src/entity/Sheep.def src/entity/PathfinderMob.def src/entity/HumanoidModel.def src/entity/TripodCameraRenderer.def @@ -43,6 +42,15 @@ set(SRC src/entity/animal/AgableMob.def src/entity/animal/Animal.def src/entity/animal/Cow.def + src/entity/animal/Chicken.def + src/entity/animal/Pig.def + src/entity/animal/Sheep.def + src/entity/monster/Creeper.def + src/entity/monster/Monster.def + src/entity/monster/PigZombie.def + src/entity/monster/Skeleton.def + src/entity/monster/Spider.def + src/entity/monster/Zombie.def src/entity/Mob.def src/entity/player/ServerPlayer.def src/entity/player/Player.def diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index 44aae8d..7a05c4e 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -1,6 +1,7 @@ virtual-method void remove() = 0x10; virtual-method void tick() = 0x34; virtual-method bool interact(Player *with) = 0x6c; +virtual-method void playerTouch(Player *player) = 0x70; virtual-method bool isPlayer() = 0x94; virtual-method bool hurt(Entity *attacker, int damage) = 0xa4; // See https://mcpirevival.miraheze.org/wiki/Minecraft:_Pi_Edition_Complete_Entity_List for these two @@ -30,9 +31,7 @@ property float yaw = 0x40; property float pitch = 0x44; property float old_yaw = 0x48; property float old_pitch = 0x4c; -property float head_height = 0x68; -property float hitbox_width = 0x6c; -property float hitbox_height = 0x70; +property AABB aabb = 0x50; property int renderer_id = 0xa8; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; diff --git a/symbols/src/entity/ItemEntity.def b/symbols/src/entity/ItemEntity.def index e132c7e..733dc3b 100644 --- a/symbols/src/entity/ItemEntity.def +++ b/symbols/src/entity/ItemEntity.def @@ -1,3 +1,7 @@ -extends Item; +extends Entity; + +vtable 0x10c5b0; +constructor (Level *level, float x, float y, float z, ItemInstance *item) = 0x86d70; property ItemInstance item = 0xd0; +property int age = 0xdc; diff --git a/symbols/src/entity/Mob.def b/symbols/src/entity/Mob.def index c540f84..476704d 100644 --- a/symbols/src/entity/Mob.def +++ b/symbols/src/entity/Mob.def @@ -7,6 +7,7 @@ constructor (Level *level) = 0x81b80; virtual-method void actuallyHurt(int damage) = 0x16c; virtual-method void die(Entity *cause) = 0x130; virtual-method ItemInstance *getCarriedItem() = 0x1ac; +virtual-method void updateAi() = 0x1cc; virtual-method float getWalkingSpeedModifier() = 0x1e8; property int health = 0xec; diff --git a/symbols/src/entity/PathfinderMob.def b/symbols/src/entity/PathfinderMob.def index b29a22b..2f27059 100644 --- a/symbols/src/entity/PathfinderMob.def +++ b/symbols/src/entity/PathfinderMob.def @@ -1,3 +1,8 @@ extends Mob; +vtable 0x10b218; + virtual-method Entity *findAttackTarget() = 0x204; + +property int target_id = 0xbe0; +property int running_away_timer = 0xbe8; diff --git a/symbols/src/entity/animal/Animal.def b/symbols/src/entity/animal/Animal.def index 4a1cfcd..bab8e39 100644 --- a/symbols/src/entity/animal/Animal.def +++ b/symbols/src/entity/animal/Animal.def @@ -1 +1,3 @@ extends AgableMob; + +vtable 0x10b588; diff --git a/symbols/src/entity/animal/Chicken.def b/symbols/src/entity/animal/Chicken.def new file mode 100644 index 0000000..5f72678 --- /dev/null +++ b/symbols/src/entity/animal/Chicken.def @@ -0,0 +1,4 @@ +extends Animal; + +vtable 0x10b7d0; +constructor (Level *level) = 0x855a0; \ No newline at end of file diff --git a/symbols/src/entity/animal/Cow.def b/symbols/src/entity/animal/Cow.def index f18dd75..3e654d0 100644 --- a/symbols/src/entity/animal/Cow.def +++ b/symbols/src/entity/animal/Cow.def @@ -1,3 +1,4 @@ extends Animal; vtable 0x10ba38; +constructor (Level *level) = 0x857f4; \ No newline at end of file diff --git a/symbols/src/entity/animal/Pig.def b/symbols/src/entity/animal/Pig.def new file mode 100644 index 0000000..5e9e769 --- /dev/null +++ b/symbols/src/entity/animal/Pig.def @@ -0,0 +1,4 @@ +extends Animal; + +vtable 0x10bc90; +constructor (Level *level) = 0x85948; diff --git a/symbols/src/entity/Sheep.def b/symbols/src/entity/animal/Sheep.def similarity index 51% rename from symbols/src/entity/Sheep.def rename to symbols/src/entity/animal/Sheep.def index 681a9dc..335d6ad 100644 --- a/symbols/src/entity/Sheep.def +++ b/symbols/src/entity/animal/Sheep.def @@ -1,3 +1,6 @@ extends Animal; +vtable 0x10bef0; +constructor (Level *level) = 0x85da0; + method void setColor(int color) = 0x86274; diff --git a/symbols/src/entity/monster/Creeper.def b/symbols/src/entity/monster/Creeper.def new file mode 100644 index 0000000..60af847 --- /dev/null +++ b/symbols/src/entity/monster/Creeper.def @@ -0,0 +1,4 @@ +extends Monster; + +vtable 0x10ca90; +constructor (Level *level) = 0x87fe8; diff --git a/symbols/src/entity/monster/Monster.def b/symbols/src/entity/monster/Monster.def new file mode 100644 index 0000000..f676f01 --- /dev/null +++ b/symbols/src/entity/monster/Monster.def @@ -0,0 +1,4 @@ +extends PathfinderMob; + +vtable 0x10cd10; +constructor (Level *level) = 0x885c0; diff --git a/symbols/src/entity/monster/PigZombie.def b/symbols/src/entity/monster/PigZombie.def new file mode 100644 index 0000000..4f26ef6 --- /dev/null +++ b/symbols/src/entity/monster/PigZombie.def @@ -0,0 +1,4 @@ +extends Monster; + +vtable 0x10cf50; +constructor (Level *level) = 0x88b4c; diff --git a/symbols/src/entity/monster/Skeleton.def b/symbols/src/entity/monster/Skeleton.def new file mode 100644 index 0000000..5f0148a --- /dev/null +++ b/symbols/src/entity/monster/Skeleton.def @@ -0,0 +1,4 @@ +extends Monster; + +vtable 0x10d208; +constructor (Level *level) = 0x89350; \ No newline at end of file diff --git a/symbols/src/entity/monster/Spider.def b/symbols/src/entity/monster/Spider.def new file mode 100644 index 0000000..c855ed2 --- /dev/null +++ b/symbols/src/entity/monster/Spider.def @@ -0,0 +1,4 @@ +extends Monster; + +vtable 0x10d490; +constructor (Level *level) = 0x89618; \ No newline at end of file diff --git a/symbols/src/entity/monster/Zombie.def b/symbols/src/entity/monster/Zombie.def new file mode 100644 index 0000000..f77ef0b --- /dev/null +++ b/symbols/src/entity/monster/Zombie.def @@ -0,0 +1,4 @@ +extends Monster; + +vtable 0x10d8a0; +constructor (Level *level) = 0x89cc8; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index 289b010..b937e36 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -15,6 +15,8 @@ virtual-method ItemInstance useTimeDepleted(ItemInstance *item_instance, Level * virtual-method int getDestorySpeed(ItemInstance *item_instance, Tile *tile) = 0x2c; virtual-method ItemInstance *use(ItemInstance *item_instance, Level *level, Player *player) = 0x30; virtual-method bool mineBlock(ItemInstance *instance, int tile_id, int x, int y, int z) = 0x48; +// Not just enemy, but any entity +virtual-method void interactEnemy(ItemInstance *item_instance, Mob *mob) = 0x54; virtual-method bool isFood() = 0x64; virtual-method bool isArmor() = 0x68; virtual-method void setDescriptionId(std::string *name) = 0x6c; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 15220bc..d9548ad 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -11,6 +11,10 @@ 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 void playSound(Entity *entity, std::string *name, float volume, float pitch) = 0xa42a8; +// 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 *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; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; -- 2.40.1 From d83eeaf2724c5f41b41e4c4f711e88502137f7d0 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 8 Feb 2024 19:33:44 -0500 Subject: [PATCH 2/7] Rename Entity::aabb to Entity::hitbox --- symbols/src/entity/Entity.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index 7a05c4e..29c3181 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -31,7 +31,7 @@ property float yaw = 0x40; property float pitch = 0x44; property float old_yaw = 0x48; property float old_pitch = 0x4c; -property AABB aabb = 0x50; +property AABB hitbox = 0x50; property int renderer_id = 0xa8; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; -- 2.40.1 From e707102192dca9e869927c102f9b1d88cba6bee0 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 12 Feb 2024 02:29:35 -0500 Subject: [PATCH 3/7] 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 5d66620..fc7d8b6 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 eeb61ff..c667a07 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 4a842aa..6c0071d 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 6164818..6b4880b 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 bab8e39..3e942ff 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 ac3f3ed..aace45e 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 6a07e7b..6726ce1 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 d9548ad..14b50f9 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 0000000..bd3a465 --- /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 0000000..e12be66 --- /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 497cbff..09ec176 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 0000000..2d0fec2 --- /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 60aacc2..62270ae 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 37f81cc..68c0064 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 0000000..dfa1b28 --- /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 0000000..92d67cd --- /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 0000000..57434d7 --- /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; -- 2.40.1 From 53d1971ae039dd02d0ad08c8011b03da9fad211a Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 12 Feb 2024 18:31:05 -0500 Subject: [PATCH 4/7] More symbols and better patch error message --- libreborn/src/patch/patch.c | 2 +- symbols/src/entity/Entity.def | 1 + symbols/src/item/Item.def | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libreborn/src/patch/patch.c b/libreborn/src/patch/patch.c index 488cc40..5ca28b1 100644 --- a/libreborn/src/patch/patch.c +++ b/libreborn/src/patch/patch.c @@ -182,7 +182,7 @@ void _overwrite(const char *file, int line, void *start, void *target) { // Patch Instruction void _patch(const char *file, int line, void *start, unsigned char patch[4]) { if (((uint32_t) start) % 4 != 0) { - ERR("Invalid Address"); + ERR("Invalid Address: %p", start); } size_t page_size = sysconf(_SC_PAGESIZE); diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index 29c3181..e9ca743 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -32,6 +32,7 @@ property float pitch = 0x44; property float old_yaw = 0x48; property float old_pitch = 0x4c; property AABB hitbox = 0x50; +property int fire_timer = 0xa0; property int renderer_id = 0xa8; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index b937e36..107f2ca 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -14,6 +14,7 @@ virtual-method int getUseDuration(ItemInstance *item_instance) = 0x24; virtual-method ItemInstance useTimeDepleted(ItemInstance *item_instance, Level *level, Player *player) = 0x28; virtual-method int getDestorySpeed(ItemInstance *item_instance, Tile *tile) = 0x2c; virtual-method ItemInstance *use(ItemInstance *item_instance, Level *level, Player *player) = 0x30; +virtual-method void hurtEnemy(ItemInstance *itemInstance, Mob *mob) = 0x44; virtual-method bool mineBlock(ItemInstance *instance, int tile_id, int x, int y, int z) = 0x48; // Not just enemy, but any entity virtual-method void interactEnemy(ItemInstance *item_instance, Mob *mob) = 0x54; -- 2.40.1 From 64cb51e37ccc5cf2121dfe4110378e9393a29d64 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 13 Feb 2024 01:18:29 -0500 Subject: [PATCH 5/7] Fix invalid ItemInHandRenderer texture cache --- mods/src/misc/misc.c | 6 ++++++ symbols/CMakeLists.txt | 1 + symbols/src/entity/PrimedTnt.def | 2 ++ symbols/src/game/mode/GameMode.def | 4 ++++ symbols/src/tile/DoorTile.def | 5 +++++ 5 files changed, 18 insertions(+) create mode 100644 symbols/src/tile/DoorTile.def diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index f1a8b97..9cd0fea 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -833,6 +833,12 @@ void init_misc() { overwrite_calls((void *) Player_startUsingItem, (void *) Player_startUsingItem_injection); overwrite_calls((void *) Player_stopUsingItem, (void *) Player_stopUsingItem_injection); + // Fix invalid ItemInHandRenderer texture cache + uchar cmp_r7_patch[] = {0x07, 0x00, 0x57, 0xe1}; // "cmp r7,r7" + patch((void *) 0x4b938, cmp_r7_patch); + uchar moveq_r3_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3,#0x1" + patch((void *) 0x4b93c, moveq_r3_true_patch); + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 6c0071d..2cd7abb 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -130,6 +130,7 @@ set(SRC src/app-platform/AppPlatform_linux.def src/app-platform/AppPlatform_readAssetFile_return_value.def src/tile/LeafTile.def + src/tile/DoorTile.def src/tile/Tile.def src/tile/LiquidTile.def src/tile/TallGrass.def diff --git a/symbols/src/entity/PrimedTnt.def b/symbols/src/entity/PrimedTnt.def index 6bff54b..42e94f3 100644 --- a/symbols/src/entity/PrimedTnt.def +++ b/symbols/src/entity/PrimedTnt.def @@ -1,3 +1,5 @@ extends Entity; +vtable 0x10c718; + property int fuse = 0xd0; diff --git a/symbols/src/game/mode/GameMode.def b/symbols/src/game/mode/GameMode.def index 128e258..e16c782 100644 --- a/symbols/src/game/mode/GameMode.def +++ b/symbols/src/game/mode/GameMode.def @@ -1 +1,5 @@ +vtable 0x102e58; +vtable-size 0x60; + +virtual-method void attack(Player *player, Entity *target) = 0x44; virtual-method void releaseUsingItem(Player *player) = 0x5c; diff --git a/symbols/src/tile/DoorTile.def b/symbols/src/tile/DoorTile.def new file mode 100644 index 0000000..5fa3e63 --- /dev/null +++ b/symbols/src/tile/DoorTile.def @@ -0,0 +1,5 @@ +extends Tile; + +vtable 0x111220; + +static-method uint getCompositeData(LevelSource *level, int x, int y, int z) = 0xbde40; -- 2.40.1 From ee4e9103f0e7954553a168ade54e54f80fb8147b Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 15 Feb 2024 02:50:15 -0500 Subject: [PATCH 6/7] Better comment --- mods/src/misc/misc.c | 10 ++++++---- symbols/src/entity/Entity.def | 1 + symbols/src/entity/EntityRenderDispatcher.def | 2 ++ symbols/src/level/container/Container.def | 2 ++ symbols/src/level/container/Inventory.def | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 9cd0fea..20ba333 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -834,10 +834,12 @@ void init_misc() { overwrite_calls((void *) Player_stopUsingItem, (void *) Player_stopUsingItem_injection); // Fix invalid ItemInHandRenderer texture cache - uchar cmp_r7_patch[] = {0x07, 0x00, 0x57, 0xe1}; // "cmp r7,r7" - patch((void *) 0x4b938, cmp_r7_patch); - uchar moveq_r3_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3,#0x1" - patch((void *) 0x4b93c, moveq_r3_true_patch); + // This works by forcing MCPI to always use the branch that enables using the + // cache, but then patches that as well to do the opposite + uchar ensure_equal_patch[] = {0x07, 0x00, 0x57, 0xe1}; // "cmp r7,r7" + patch((void *) 0x4b938, ensure_equal_patch); + uchar set_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3,#0x1" + patch((void *) 0x4b93c, set_true_patch); // Init C++ And Logging _init_misc_cpp(); diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index e9ca743..ec7a88b 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -32,6 +32,7 @@ property float pitch = 0x44; property float old_yaw = 0x48; property float old_pitch = 0x4c; property AABB hitbox = 0x50; +property float height_offset = 0x68; property int fire_timer = 0xa0; property int renderer_id = 0xa8; property bool on_ground = 0xb2; diff --git a/symbols/src/entity/EntityRenderDispatcher.def b/symbols/src/entity/EntityRenderDispatcher.def index d678fc4..355dc45 100644 --- a/symbols/src/entity/EntityRenderDispatcher.def +++ b/symbols/src/entity/EntityRenderDispatcher.def @@ -1,3 +1,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; diff --git a/symbols/src/level/container/Container.def b/symbols/src/level/container/Container.def index 3b89373..b14460d 100644 --- a/symbols/src/level/container/Container.def +++ b/symbols/src/level/container/Container.def @@ -2,3 +2,5 @@ virtual-method void startOpen() = 0x24; virtual-method void stopOpen() = 0x28; virtual-method ItemInstance *getItem(int slot) = 0x8; virtual-method void setItem(int slot, ItemInstance *item_instance) = 0xc; +virtual-method int getContainerSize() = 0x18; +virtual-method std::vector getSlotCopies() = 0x2c; diff --git a/symbols/src/level/container/Inventory.def b/symbols/src/level/container/Inventory.def index 1108f0b..7a1158c 100644 --- a/symbols/src/level/container/Inventory.def +++ b/symbols/src/level/container/Inventory.def @@ -5,5 +5,6 @@ method void selectSlot(int slot) = 0x8d13c; 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; property int selectedSlot = 0x28; -- 2.40.1 From 68fb38cc814a2160db871b13802470efeee0ded8 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 15 Feb 2024 04:01:55 -0500 Subject: [PATCH 7/7] Remobe comment --- symbols/src/tile/entity/TileEntity.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/symbols/src/tile/entity/TileEntity.def b/symbols/src/tile/entity/TileEntity.def index 68c0064..a3f6a45 100644 --- a/symbols/src/tile/entity/TileEntity.def +++ b/symbols/src/tile/entity/TileEntity.def @@ -22,5 +22,3 @@ property bool is_client = 0x20; property int renderer_id = 0x24; property Tile *tile = 0x28; property bool pending_removal = 0x2c; -//property int tile = 0xd0; -//property int lifetime = 0xd8; -- 2.40.1