diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 64504ad10a..46570de494 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 93360c2354..4a842aa982 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 44aae8d376..7a05c4ea4e 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 e132c7e950..733dc3b9fc 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 c540f84966..476704d24e 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 b29a22b439..2f270591df 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 4a1cfcd1da..bab8e39764 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 0000000000..5f72678830 --- /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 f18dd750b9..3e654d0c05 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 0000000000..5e9e7697d9 --- /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 681a9dcd1e..335d6adcef 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 0000000000..60af847b60 --- /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 0000000000..f676f019b4 --- /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 0000000000..4f26ef6ce4 --- /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 0000000000..5f0148ae7b --- /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 0000000000..c855ed2bee --- /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 0000000000..f77ef0ba91 --- /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 289b010230..b937e36810 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 15220bc8ee..d9548ad9cd 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;