Skip to content

Commit 1d375a3

Browse files
authored
feat(world): decomp LivingEntity.setBoundingBox (#47)
1 parent 27eab94 commit 1d375a3

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

data/mcswitch_functions.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15231,7 +15231,7 @@ Address,Quality,Size,Name
1523115231
0x000000710021eae4,U,000056,_ZN19MultiPlayerGameMode10isCutSceneEv
1523215232
0x000000710021eb1c,U,000652,
1523315233
0x000000710021eda8,U,001112,_ZN12LivingEntity13getLightColorEv
15234-
0x000000710021f200,U,000240,_ZN12LivingEntity14setBoundingBoxEP4AABB
15234+
0x000000710021f200,O,000240,_ZN12LivingEntity14setBoundingBoxEP4AABB
1523515235
0x000000710021f2f0,U,000008,_ZN12LivingEntity8getSpeedEv
1523615236
0x000000710021f2f8,U,000008,_ZN12LivingEntity8setSpeedEf
1523715237
0x000000710021f300,U,000092,_ZN12LivingEntity12doHurtTargetENSt3__110shared_ptrI6EntityEE

src/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@
2323
eINSTANCEOF LivingEntity::GetType() {
2424
return eLivingEntity;
2525
}
26+
void LivingEntity::setBoundingBox(AABB* box) {
27+
const int newMinX = Mth::floor(box->min.x);
28+
const int newMaxX = Mth::floor(box->max.x);
29+
const int newMinY = Mth::floor(box->min.y);
30+
const int newMaxY = Mth::floor(box->max.y);
31+
const int newMinZ = Mth::floor(box->min.z);
32+
const int newMaxZ = Mth::floor(box->max.z);
33+
34+
const int oldMinX = this->mMinX;
35+
const int oldMaxX = this->mMaxX;
36+
const int oldMinY = this->mMinY;
37+
const int oldMaxY = this->mMaxY;
38+
const int oldMinZ = this->mMinZ;
39+
const int oldMaxZ = this->mMaxZ;
40+
41+
this->mMinX = newMinX;
42+
this->mMaxX = newMaxX;
43+
this->mMinY = newMinY;
44+
this->mMaxY = newMaxY;
45+
this->mMinZ = newMinZ;
46+
this->mMaxZ = newMaxZ;
47+
48+
if (newMinX != oldMinX || newMaxX != oldMaxX || newMinY != oldMinY || newMaxY != oldMaxY
49+
|| newMinZ != oldMinZ || newMaxZ != oldMaxZ) {
50+
++this->dword50C;
51+
}
52+
this->Entity::setBoundingBox(box);
53+
}
2654

2755
void LivingEntity::dropEquipment(bool, int) {}
2856
void LivingEntity::dropDeathLoot(bool, int) {}

src/Minecraft.World/net/minecraft/world/entity/LivingEntity.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LivingEntity : public Entity {
5454
void setYBodyRot(float) override;
5555
void shouldShowName() override;
5656
void onSyncedDataUpdated(const EntityDataAccessor_Base*) override;
57-
void setBoundingBox(AABB*) override;
57+
void setBoundingBox(AABB* box) override;
5858
void stopCurrentLerp() override;
5959
virtual void registerAttributes();
6060
virtual bool isWaterMob();
@@ -270,8 +270,12 @@ class LivingEntity : public Entity {
270270
long mLastDamageStamp;
271271
char byte508;
272272
int dword50C;
273-
void* qword510;
274-
void* qword518;
273+
int mMinX;
274+
int mMaxX;
275+
int mMinY;
276+
int mMaxY;
277+
int mMinZ;
278+
int mMaxZ;
275279
void* qword520;
276280
char gap528[128];
277281
char byte5A8;

0 commit comments

Comments
 (0)