Skip to content

Commit 15b6e33

Browse files
committed
Fix DamageSource mismatches
1 parent c6da97c commit 15b6e33

5 files changed

Lines changed: 36 additions & 46 deletions

File tree

data/mcswitch_functions.csv

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6674,7 +6674,7 @@ Address,Quality,Size,Name
66746674
0x00000071000f4234,U,000016,_ZN12DamageSource12bypassArmourEv
66756675
0x00000071000f4244,U,000016,
66766676
0x00000071000f4254,U,000012,
6677-
0x00000071000f4260,O,000012,_ZN18EntityDamageSource9setThornsEv
6677+
0x00000071000f4260,O,000012,_ZN12DamageSource8setMagicEv
66786678
0x00000071000f426c,U,000012,
66796679
0x00000071000f4278,U,000164,
66806680
0x00000071000f431c,U,000120,_ZN12DamageSource12CreateThornsENSt3__110shared_ptrI6EntityEE
@@ -6707,7 +6707,7 @@ Address,Quality,Size,Name
67076707
0x00000071000f4e74,U,000008,_ZN12DamageSource6isFireEv
67086708
0x00000071000f4e7c,U,000008,
67096709
0x00000071000f4e84,U,000160,
6710-
0x00000071000f4f24,M,000052,_ZN12DamageSource4copyEv
6710+
0x00000071000f4f24,O,000052,_ZN12DamageSource4copyEv
67116711
0x00000071000f4f58,U,000044,_ZN12DamageSourceC_gen
67126712
0x00000071000f4f84,O,000008,_ZN12DamageSource17getSourcePositionEv
67136713
0x00000071000f4f8c,U,000004,_ZN12DamageSource19GetBaseDamageSourceEv
@@ -10117,14 +10117,14 @@ Address,Quality,Size,Name
1011710117
0x000000710015b184,U,000092,
1011810118
0x000000710015b1e0,U,000008,_ZN6Entity18getFireImmuneTicksEv
1011910119
0x000000710015b1e8,O,000144,_ZN18EntityDamageSourceC1EN21ClientboundChatPacket18EChatPacketMessageES1_NSt3__110shared_ptrI6EntityEE
10120-
0x000000710015b278,O,000012,_ZN12DamageSource8setMagicEv
10120+
0x000000710015b278,O,000012,_ZN18EntityDamageSource9setThornsEv
1012110121
0x000000710015b284,U,000008,
10122-
0x000000710015b28c,M,000028,_ZN18EntityDamageSource9getEntityEv
10122+
0x000000710015b28c,O,000028,_ZN18EntityDamageSource9getEntityEv
1012310123
0x000000710015b2a8,U,000824,_ZN18EntityDamageSource21getDeathMessagePacketENSt3__110shared_ptrI12LivingEntityEE
10124-
0x000000710015b5e0,M,000076,_ZN18EntityDamageSource20scalesWithDifficultyEv
10125-
0x000000710015b62c,M,000052,_ZN18EntityDamageSource4copyEv
10124+
0x000000710015b5e0,O,000076,_ZN18EntityDamageSource20scalesWithDifficultyEv
10125+
0x000000710015b62c,O,000052,_ZN18EntityDamageSource4copyEv
1012610126
0x000000710015b660,U,000084,_ZN18EntityDamageSourceC_gen2
10127-
0x000000710015b6b4,M,000016,_ZN18EntityDamageSource17getSourcePositionEv
10127+
0x000000710015b6b4,O,000016,_ZN18EntityDamageSource17getSourcePositionEv
1012810128
0x000000710015b6c4,U,000048,_ZN21EntityDataSerializers25BYTE_EntityDataSerializerC_gen
1012910129
0x000000710015b6f4,U,000040,_ZN20EntityDataSerializerIhEC_gen
1013010130
0x000000710015b71c,U,000020,
@@ -12372,19 +12372,19 @@ Address,Quality,Size,Name
1237212372
0x00000071001a6eac,U,000120,
1237312373
0x00000071001a6f24,U,000152,_ZN5Horse14addDataWalkersEP14DataFixerUpper
1237412374
0x00000071001a6fbc,U,000300,
12375-
0x00000071001a70e8,U,000020,
12375+
0x00000071001a70e8,U,000020,getVariant__5HorseFv
1237612376
0x00000071001a70fc,U,000392,
1237712377
0x00000071001a7284,U,000064,
1237812378
0x00000071001a72c4,U,000084,
1237912379
0x00000071001a7318,U,000084,
12380-
0x00000071001a736c,U,000720,
12381-
0x00000071001a763c,U,000112,
12382-
0x00000071001a76ac,U,000016,
12383-
0x00000071001a76bc,U,000032,
12380+
0x00000071001a736c,U,000720,rebuildLayeredTextureInfo__5HorseFv
12381+
0x00000071001a763c,U,000112,getArmorType__5HorseFv
12382+
0x00000071001a76ac,U,000016,getTextureCount__14HorseArmorItemCFv
12383+
0x00000071001a76bc,U,000032,getTexture__14HorseArmorItemCFi
1238412384
0x00000071001a76dc,O,000128,_ZNSt3__1plIwNS_11char_traitsIwEENS_9allocatorIwEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_
12385-
0x00000071001a775c,U,000012,
12386-
0x00000071001a7768,U,000072,
12387-
0x00000071001a77b0,U,000072,
12385+
0x00000071001a775c,U,000012,getHash__14HorseArmorItemCFv
12386+
0x00000071001a7768,U,000072,getLayeredTextureHashName__5HorseFv
12387+
0x00000071001a77b0,U,000072,getLayeredTextureLayers__5HorseFv
1238812388
0x00000071001a77f8,U,000076,
1238912389
0x00000071001a7844,U,000028,
1239012390
0x00000071001a7860,U,000096,
@@ -13055,7 +13055,7 @@ Address,Quality,Size,Name
1305513055
0x00000071001cf3f8,O,000024,_ZN20KnockbackEnchantment10getMaxCostEi
1305613056
0x00000071001cf410,O,000008,_ZN20KnockbackEnchantment11getMaxLevelEv
1305713057
0x00000071001cf418,O,000036,_ZN4ItemD0Ev
13058-
0x00000071001cf43c,M,000052,_ZN18EntityDamageSourceD1Ev
13058+
0x00000071001cf43c,O,000052,_ZN18EntityDamageSourceD1Ev
1305913059
0x00000071001cf470,O,000036,_ZN18EntityDamageSourceD0Ev
1306013060
0x00000071001cf494,U,000052,_ZN26IndirectEntityDamageSourceD2Ev
1306113061
0x00000071001cf4c8,U,000036,_ZN26IndirectEntityDamageSourceD0Ev
@@ -42179,7 +42179,7 @@ Address,Quality,Size,Name
4217942179
0x00000071006abab4,U,000132,_ZN13HorseRendererC_gen
4218042180
0x00000071006abb38,U,000664,
4218142181
0x00000071006abdd0,U,000012,
42182-
0x00000071006abddc,U,000204,
42182+
0x00000071006abddc,U,000204,getTextureLocation__13HorseRendererFRQ2_5boost25shared_ptr__tm__8_6Entity
4218342183
0x00000071006abea8,U,000052,
4218442184
0x00000071006abedc,U,000056,
4218542185
0x00000071006abf14,U,000256,_ZN21HugeExplosionParticleC_gen
@@ -43500,7 +43500,7 @@ Address,Quality,Size,Name
4350043500
0x00000071006f8890,U,000036,_ZN11PigRendererD0Ev
4350143501
0x00000071006f88b4,U,000036,_ZN15LargeChestModelD0Ev
4350243502
0x00000071006f88d8,U,000012,
43503-
0x00000071006f88e4,U,000068,_ZN8ParticleC_gen3
43503+
0x00000071006f88e4,U,000068,_ZN8ParticleD2Ev
4350443504
0x00000071006f8928,U,000036,_ZN18LargeSmokeParticleD0Ev
4350543505
0x00000071006f894c,U,000036,_ZN23MinecartSpawnerRendererD0Ev
4350643506
0x00000071006f8970,U,000036,_ZN8PigModelD0Ev

src/Minecraft.World/net/minecraft/world/damagesource/DamageSource.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,50 @@ DamageSource::DamageSource(ClientboundChatPacket::EChatPacketMessage unk0,
1010
this->mIsFireSource = false;
1111
this->mIsExplosion = false;
1212
this->mScalesWithDifficulty = false;
13-
this->mIsThorns = false;
13+
this->mIsMagic = false;
1414
this->mIsProjectile = false;
1515
this->field_0x15 = false;
1616
this->field_0x18 = unk0;
17-
this->field_0x1a = unk1;
17+
this->field_0x1c = unk1;
1818
}
19+
1920
std::shared_ptr<Entity> DamageSource::getDirectEntity() {
2021
return this->getEntity();
2122
}
23+
2224
std::shared_ptr<Entity> DamageSource::getEntity() {
2325
return nullptr;
2426
}
27+
2528
bool DamageSource::scalesWithDifficulty() {
2629
return this->mScalesWithDifficulty;
2730
}
31+
2832
Vec3* DamageSource::getSourcePosition() {
2933
return nullptr;
3034
}
31-
// NON_MATCHING | Score: 10
32-
// stop whining about std::shared_ptr<Entity> mEntity offset.
33-
// also why is target using 'orr', but current is using 'mov'??
35+
3436
DamageSource* DamageSource::copy() {
3537
return new DamageSource(*this);
3638
}
39+
3740
DamageSource* DamageSource::setMagic() {
3841
this->mIsMagic = true;
3942
return this;
4043
}
44+
4145
bool DamageSource::isBypassInvul() const {
4246
return this->mBypassInvul;
4347
}
48+
4449
bool DamageSource::isFire() const {
4550
return this->mIsFireSource;
4651
}
52+
4753
bool DamageSource::isProjectile() const {
4854
return this->mIsProjectile;
4955
}
56+
5057
bool DamageSource::isExplosion() const {
5158
return this->mIsExplosion;
5259
}

src/Minecraft.World/net/minecraft/world/damagesource/DamageSource.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ class DamageSource {
3939
bool mIsFireSource;
4040
bool mIsExplosion;
4141
bool mScalesWithDifficulty;
42-
bool mIsThorns;
42+
bool mIsMagic;
4343
bool mIsProjectile;
4444
bool field_0x15;
4545
ClientboundChatPacket::EChatPacketMessage field_0x18;
46-
ClientboundChatPacket::EChatPacketMessage field_0x1a;
47-
bool mIsMagic;
46+
ClientboundChatPacket::EChatPacketMessage field_0x1c;
4847
};

src/Minecraft.World/net/minecraft/world/damagesource/EntityDamageSource.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11
#include "net/minecraft/world/damagesource/EntityDamageSource.h"
22

3-
// there's some wild shit going on with std::shared_ptr<Entity> mEntity
4-
// it's getting referenced by 0x28 instead of 0x20
5-
// i already tried using `unsigned short` for `EChatPacketMessage` enum, it fixes EntityDamageSource, but then
6-
// it breaks DamageSource constructor
7-
// i wish i knew why...
8-
9-
// NON_MATCHING | Score: 25 (lower is better)
10-
// mEntity is located at 0x28 instead of 0x20, read above
113
EntityDamageSource::EntityDamageSource(ClientboundChatPacket::EChatPacketMessage unk0,
124
ClientboundChatPacket::EChatPacketMessage unk1,
135
std::shared_ptr<Entity> entity)
146
: DamageSource(unk0, unk1) {
157
this->mEntity = entity;
16-
this->field_0x30 = false;
8+
this->mIsThorns = false;
179
}
1810

19-
// NON_MATCHING | Score: 10 (lower is better)
20-
// mEntity is located at 0x28 instead of 0x20, read above
2111
EntityDamageSource::~EntityDamageSource() {}
2212

23-
// NON_MATCHING | Score: 15 (lower is better)
24-
// mEntity is located at 0x28 instead of 0x20, read above
2513
std::shared_ptr<Entity> EntityDamageSource::getEntity() {
2614
return this->mEntity;
2715
}
2816

29-
// NON_MATCHING | Score: 10 (lower is better)
30-
// mEntity is located at 0x28 instead of 0x20, read above
3117
bool EntityDamageSource::scalesWithDifficulty() {
3218
return this->mEntity && this->mEntity->isType(eLivingEntity) && !this->mEntity->isType(ePlayer);
3319
}
34-
// NON_MATCHING | Score: 10 (lower is better)
35-
// mEntity is located at 0x28 instead of 0x20 and Vec3::newTemp is at wrong address
20+
3621
Vec3* EntityDamageSource::getSourcePosition() {
3722
return Vec3::newTemp(this->mEntity->mX, this->mEntity->mY, this->mEntity->mZ);
3823
}
39-
// NON_MATCHING | Score: 5 (lower is better)
40-
// continue pulling 2 extra bytes offset out of your ass
24+
4125
DamageSource* EntityDamageSource::copy() {
4226
return new EntityDamageSource(*this);
4327
}

src/Minecraft.World/net/minecraft/world/damagesource/EntityDamageSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class EntityDamageSource : public DamageSource {
2121

2222
private:
2323
std::shared_ptr<Entity> mEntity;
24-
bool field_0x30;
24+
bool mIsThorns;
2525
};

0 commit comments

Comments
 (0)