More symbols and clean up "Disable Hostile AI In Creative Mode"

This commit is contained in:
Bigjango13 2024-02-08 17:30:41 -05:00 committed by TheBrokenRail
parent b033912633
commit f57c0a6190
19 changed files with 77 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,3 +1,8 @@
extends Mob;
vtable 0x10b218;
virtual-method Entity *findAttackTarget() = 0x204;
property int target_id = 0xbe0;
property int running_away_timer = 0xbe8;

View File

@ -1 +1,3 @@
extends AgableMob;
vtable 0x10b588;

View File

@ -0,0 +1,4 @@
extends Animal;
vtable 0x10b7d0;
constructor (Level *level) = 0x855a0;

View File

@ -1,3 +1,4 @@
extends Animal;
vtable 0x10ba38;
constructor (Level *level) = 0x857f4;

View File

@ -0,0 +1,4 @@
extends Animal;
vtable 0x10bc90;
constructor (Level *level) = 0x85948;

View File

@ -1,3 +1,6 @@
extends Animal;
vtable 0x10bef0;
constructor (Level *level) = 0x85da0;
method void setColor(int color) = 0x86274;

View File

@ -0,0 +1,4 @@
extends Monster;
vtable 0x10ca90;
constructor (Level *level) = 0x87fe8;

View File

@ -0,0 +1,4 @@
extends PathfinderMob;
vtable 0x10cd10;
constructor (Level *level) = 0x885c0;

View File

@ -0,0 +1,4 @@
extends Monster;
vtable 0x10cf50;
constructor (Level *level) = 0x88b4c;

View File

@ -0,0 +1,4 @@
extends Monster;
vtable 0x10d208;
constructor (Level *level) = 0x89350;

View File

@ -0,0 +1,4 @@
extends Monster;
vtable 0x10d490;
constructor (Level *level) = 0x89618;

View File

@ -0,0 +1,4 @@
extends Monster;
vtable 0x10d8a0;
constructor (Level *level) = 0x89cc8;

View File

@ -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;

View File

@ -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<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;
virtual-method void tick() = 0x28;
virtual-method void updateSleepingPlayerList() = 0x2c;