Skip to content

Commit 5bb4549

Browse files
Fix entity armor not showing on death animation (#7355)
1 parent 286bd1b commit 5bb4549

22 files changed

+87
-76
lines changed

build-data/paper.at

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public net.minecraft.server.level.ChunkMap getPoiManager()Lnet/minecraft/world/e
7272
# Improve death events
7373
public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sounds/SoundEvent;
7474
public net.minecraft.world.entity.LivingEntity getSoundVolume()F
75-
public net.minecraft.world.entity.Mob handItems
76-
public net.minecraft.world.entity.Mob armorItems
7775

7876
# Add sun related api
7977
public net.minecraft.world.entity.Mob isSunBurnTick()Z

patches/server/0260-Improve-death-events.patch

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ index fd1937f49312204d38510996a5be43b731f38bde..a2e2b6ea166bf64fe5b49672a6c6f86a
7070
}
7171
}
7272
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
73-
index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce12141aa5a92e 100644
73+
index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..cd3f18a7484817c5bc7c53585f6deb8889744c0b 100644
7474
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
7575
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
7676
@@ -257,6 +257,7 @@ public abstract class LivingEntity extends Entity {
@@ -108,7 +108,7 @@ index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce1214
108108
if (this.deathScore >= 0 && entityliving != null) {
109109
entityliving.awardKillScore(this, this.deathScore, source);
110110
}
111-
@@ -1606,20 +1606,52 @@ public abstract class LivingEntity extends Entity {
111+
@@ -1606,20 +1606,54 @@ public abstract class LivingEntity extends Entity {
112112
if (!this.level.isClientSide && this.hasCustomName()) {
113113
if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot
114114
}
@@ -131,9 +131,11 @@ index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce1214
131131
+ entityliving.awardKillScore(this, this.deathScore, source);
132132
+ }
133133
+ // Paper start - clear equipment if event is not cancelled
134-
+ if (this instanceof Mob mob) {
135-
+ java.util.Collections.fill(mob.handItems, ItemStack.EMPTY);
136-
+ java.util.Collections.fill(mob.armorItems, ItemStack.EMPTY);
134+
+ if (this instanceof Mob) {
135+
+ for (EquipmentSlot slot : this.clearedEquipmentSlots) {
136+
+ this.setItemSlot(slot, ItemStack.EMPTY);
137+
+ }
138+
+ this.clearedEquipmentSlots.clear();
137139
+ }
138140
+ // Paper end
139141
+
@@ -164,7 +166,7 @@ index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce1214
164166
}
165167
}
166168

167-
@@ -1627,7 +1659,7 @@ public abstract class LivingEntity extends Entity {
169+
@@ -1627,7 +1661,7 @@ public abstract class LivingEntity extends Entity {
168170
if (!this.level.isClientSide) {
169171
boolean flag = false;
170172

@@ -173,23 +175,30 @@ index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce1214
173175
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
174176
BlockPos blockposition = this.blockPosition();
175177
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
176-
@@ -1656,7 +1688,8 @@ public abstract class LivingEntity extends Entity {
178+
@@ -1656,7 +1690,11 @@ public abstract class LivingEntity extends Entity {
177179
}
178180
}
179181

180182
- protected void dropAllDeathLoot(DamageSource source) {
181-
+ protected boolean clearEquipmentSlots = true; // Paper
182-
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) { // Paper
183+
+ // Paper start
184+
+ protected boolean clearEquipmentSlots = true;
185+
+ protected Set<EquipmentSlot> clearedEquipmentSlots = new java.util.HashSet<>();
186+
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
187+
+ // Paper end
183188
Entity entity = source.getEntity();
184189
int i;
185190

186-
@@ -1671,18 +1704,23 @@ public abstract class LivingEntity extends Entity {
191+
@@ -1671,18 +1709,27 @@ public abstract class LivingEntity extends Entity {
187192
this.dropEquipment(); // CraftBukkit - from below
188193
if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
189194
this.dropFromLootTable(source, flag);
190-
+ this.clearEquipmentSlots = false; // Paper
195+
+ // Paper start
196+
+ final boolean prev = this.clearEquipmentSlots;
197+
+ this.clearEquipmentSlots = false;
198+
+ this.clearedEquipmentSlots.clear();
199+
+ // Paper end
191200
this.dropCustomDeathLoot(source, i, flag);
192-
+ this.clearEquipmentSlots = true; // Paper
201+
+ this.clearEquipmentSlots = prev; // Paper
193202
}
194203
// CraftBukkit start - Call death event
195204
- CraftEventFactory.callEntityDeathEvent(this, this.drops);
@@ -209,16 +218,20 @@ index c5d6e5c5c35fa3ab444f271c929ee88c30832dc9..a1850da0d11edfbaac5e799694ce1214
209218
// CraftBukkit start
210219
public int getExpReward() {
211220
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
212-
index b937ffef296beed853b47ded1672a2f408be674f..426b3afc7ba5229339f820062f17c1a0775a0df6 100644
221+
index b13e6bfa449599aafeb97d99c9dc1e0c3885c4be..ecd484a35f9401ffe8f0893749d8d05399166ac2 100644
213222
--- a/src/main/java/net/minecraft/world/entity/Mob.java
214223
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
215-
@@ -1002,7 +1002,9 @@ public abstract class Mob extends LivingEntity {
224+
@@ -1002,7 +1002,13 @@ public abstract class Mob extends LivingEntity {
216225
}
217226

218227
this.spawnAtLocation(itemstack);
219228
+ if (this.clearEquipmentSlots) { // Paper
220229
this.setItemSlot(enumitemslot, ItemStack.EMPTY);
221-
+ } // Paper
230+
+ // Paper start
231+
+ } else {
232+
+ this.clearedEquipmentSlots.add(enumitemslot);
233+
+ }
234+
+ // Paper end
222235
}
223236
}
224237

patches/server/0273-Add-LivingEntity-getTargetEntity.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Add LivingEntity#getTargetEntity
55

66

77
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
8-
index a1850da0d11edfbaac5e799694ce12141aa5a92e..7886d276e4919cb57372bd0475aaf83992cde360 100644
8+
index cd3f18a7484817c5bc7c53585f6deb8889744c0b..dc723e1a4d73e06c4b9f275c7b912de1a1cef070 100644
99
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1010
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
1111
@@ -113,6 +113,7 @@ import net.minecraft.world.level.storage.loot.LootTable;
@@ -16,7 +16,7 @@ index a1850da0d11edfbaac5e799694ce12141aa5a92e..7886d276e4919cb57372bd0475aaf839
1616
import net.minecraft.world.phys.HitResult;
1717
import net.minecraft.world.phys.Vec3;
1818
import net.minecraft.world.scores.PlayerTeam;
19-
@@ -3744,6 +3745,38 @@ public abstract class LivingEntity extends Entity {
19+
@@ -3753,6 +3754,38 @@ public abstract class LivingEntity extends Entity {
2020
return level.clip(raytrace);
2121
}
2222

patches/server/0293-force-entity-dismount-during-teleportation.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ index db7f2715534ed71a2b285de095238586fe6a35b0..f51c416e7938b7905f7efb154ab14cad
4141

4242
if (entity1 != entity && this.connection != null) {
4343
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
44-
index d53d968d92e7491c3802d6f9215710610ef11ce5..8018c9dae36335c2fb654269684445b6411450ee 100644
44+
index 37f337efb7ac164749c73974e4acfde93d649290..3a013ffe5feec6dab478684964f581c354f2a7ae 100644
4545
--- a/src/main/java/net/minecraft/world/entity/Entity.java
4646
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
4747
@@ -2252,11 +2252,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@@ -93,10 +93,10 @@ index d53d968d92e7491c3802d6f9215710610ef11ce5..8018c9dae36335c2fb654269684445b6
9393
if (this.valid) {
9494
Bukkit.getPluginManager().callEvent(event);
9595
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
96-
index 7886d276e4919cb57372bd0475aaf83992cde360..0031a3a4850e38039c37550d6f67e433b9143cfd 100644
96+
index dc723e1a4d73e06c4b9f275c7b912de1a1cef070..8587ac23b5c98ef2ee90445432da9db130d93464 100644
9797
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
9898
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
99-
@@ -3343,9 +3343,15 @@ public abstract class LivingEntity extends Entity {
99+
@@ -3352,9 +3352,15 @@ public abstract class LivingEntity extends Entity {
100100

101101
@Override
102102
public void stopRiding() {

patches/server/0338-Prevent-consuming-the-wrong-itemstack.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Prevent consuming the wrong itemstack
55

66

77
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
8-
index 0031a3a4850e38039c37550d6f67e433b9143cfd..fa07a6f7ec215652861a62a0cb942522e0f4f655 100644
8+
index 8587ac23b5c98ef2ee90445432da9db130d93464..d3bb82817e595a946a8294a059982924226ebfa7 100644
99
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1010
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
11-
@@ -3565,9 +3565,14 @@ public abstract class LivingEntity extends Entity {
11+
@@ -3574,9 +3574,14 @@ public abstract class LivingEntity extends Entity {
1212
}
1313

1414
public void startUsingItem(InteractionHand hand) {
@@ -24,15 +24,15 @@ index 0031a3a4850e38039c37550d6f67e433b9143cfd..fa07a6f7ec215652861a62a0cb942522
2424
this.useItem = itemstack;
2525
this.useItemRemaining = itemstack.getUseDuration();
2626
if (!this.level.isClientSide) {
27-
@@ -3646,6 +3651,7 @@ public abstract class LivingEntity extends Entity {
27+
@@ -3655,6 +3660,7 @@ public abstract class LivingEntity extends Entity {
2828
this.releaseUsingItem();
2929
} else {
3030
if (!this.useItem.isEmpty() && this.isUsingItem()) {
3131
+ this.startUsingItem(this.getUsedItemHand(), true); // Paper
3232
this.triggerItemUseEffects(this.useItem, 16);
3333
// CraftBukkit start - fire PlayerItemConsumeEvent
3434
ItemStack itemstack;
35-
@@ -3680,8 +3686,8 @@ public abstract class LivingEntity extends Entity {
35+
@@ -3689,8 +3695,8 @@ public abstract class LivingEntity extends Entity {
3636
}
3737

3838
this.stopUsingItem();

patches/server/0353-Lag-compensate-eating.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ When the server is lagging, players will wait longer when eating.
77
Change to also use a time check instead if it passes.
88

99
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
10-
index fa07a6f7ec215652861a62a0cb942522e0f4f655..4bdc5e2926ec78de0948b8469c72015c8fecb520 100644
10+
index d3bb82817e595a946a8294a059982924226ebfa7..77f79aa787aae0b146f84030d07df9d71e1637c5 100644
1111
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1212
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
13-
@@ -3508,6 +3508,11 @@ public abstract class LivingEntity extends Entity {
13+
@@ -3517,6 +3517,11 @@ public abstract class LivingEntity extends Entity {
1414
return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
1515
}
1616

@@ -22,7 +22,7 @@ index fa07a6f7ec215652861a62a0cb942522e0f4f655..4bdc5e2926ec78de0948b8469c72015c
2222
private void updatingUsingItem() {
2323
if (this.isUsingItem()) {
2424
if (ItemStack.isSameIgnoreDurability(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
25-
@@ -3525,8 +3530,12 @@ public abstract class LivingEntity extends Entity {
25+
@@ -3534,8 +3539,12 @@ public abstract class LivingEntity extends Entity {
2626
if (this.shouldTriggerItemUseEffects()) {
2727
this.triggerItemUseEffects(stack, 5);
2828
}
@@ -37,7 +37,7 @@ index fa07a6f7ec215652861a62a0cb942522e0f4f655..4bdc5e2926ec78de0948b8469c72015c
3737
this.completeUsingItem();
3838
}
3939

40-
@@ -3574,7 +3583,10 @@ public abstract class LivingEntity extends Entity {
40+
@@ -3583,7 +3592,10 @@ public abstract class LivingEntity extends Entity {
4141

4242
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag
4343
this.useItem = itemstack;
@@ -49,7 +49,7 @@ index fa07a6f7ec215652861a62a0cb942522e0f4f655..4bdc5e2926ec78de0948b8469c72015c
4949
if (!this.level.isClientSide) {
5050
this.setLivingEntityFlag(1, true);
5151
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
52-
@@ -3598,7 +3610,10 @@ public abstract class LivingEntity extends Entity {
52+
@@ -3607,7 +3619,10 @@ public abstract class LivingEntity extends Entity {
5353
}
5454
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
5555
this.useItem = ItemStack.EMPTY;
@@ -61,7 +61,7 @@ index fa07a6f7ec215652861a62a0cb942522e0f4f655..4bdc5e2926ec78de0948b8469c72015c
6161
}
6262
}
6363

64-
@@ -3726,7 +3741,10 @@ public abstract class LivingEntity extends Entity {
64+
@@ -3735,7 +3750,10 @@ public abstract class LivingEntity extends Entity {
6565
}
6666

6767
this.useItem = ItemStack.EMPTY;

patches/server/0371-Entity-Jump-API.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Entity Jump API
55

66

77
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
8-
index 4bdc5e2926ec78de0948b8469c72015c8fecb520..ae2ee484ab8b70226dd25386336c109a201a6450 100644
8+
index 77f79aa787aae0b146f84030d07df9d71e1637c5..a30f71d4558040e42f061d056a2ae26db3b9ce57 100644
99
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1010
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
11-
@@ -3171,8 +3171,10 @@ public abstract class LivingEntity extends Entity {
11+
@@ -3180,8 +3180,10 @@ public abstract class LivingEntity extends Entity {
1212
} else if (this.isInLava() && (!this.onGround || d7 > d8)) {
1313
this.jumpInLiquid(FluidTags.LAVA);
1414
} else if ((this.onGround || flag && d7 <= d8) && this.noJumpDelay == 0) {

patches/server/0399-Don-t-run-entity-collision-code-if-not-needed.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Will not run if max entity craming is disabled and
77
the max collisions per entity is less than or equal to 0
88

99
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
10-
index ae2ee484ab8b70226dd25386336c109a201a6450..4963f3b2e8d2889ef79a8c4fbc84548a0010b49d 100644
10+
index a30f71d4558040e42f061d056a2ae26db3b9ce57..16d9d4ff14d032e1793a482c57338839a5ab62fb 100644
1111
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1212
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
13-
@@ -3268,10 +3268,16 @@ public abstract class LivingEntity extends Entity {
13+
@@ -3277,10 +3277,16 @@ public abstract class LivingEntity extends Entity {
1414
protected void serverAiStep() {}
1515

1616
protected void pushEntities() {

patches/server/0407-Add-PlayerAttackEntityCooldownResetEvent.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
55

66

77
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
8-
index 4963f3b2e8d2889ef79a8c4fbc84548a0010b49d..ab02e0babf6289d64b44dc18f3f6f0bdd4b83c32 100644
8+
index 16d9d4ff14d032e1793a482c57338839a5ab62fb..843097979f45b8f99efbfdcf268eea4879c0239a 100644
99
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
1010
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
11-
@@ -2046,7 +2046,16 @@ public abstract class LivingEntity extends Entity {
11+
@@ -2055,7 +2055,16 @@ public abstract class LivingEntity extends Entity {
1212

1313
EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
1414
if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player) {

patches/server/0410-Fix-numerous-item-duplication-issues-and-teleport-is.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ index 6fa35e0acd966a9cfd3d5b3765c7d0130ea2de18..7bf62752b6604abe0bda6f5d0024f0e9
8080

8181
public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) {
8282
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
83-
index ab02e0babf6289d64b44dc18f3f6f0bdd4b83c32..198a0cfb222f40e792a9723eb25c514889ffe01f 100644
83+
index 843097979f45b8f99efbfdcf268eea4879c0239a..9d8912ff91932e5e3c9a708b4c850e8abaa1a605 100644
8484
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
8585
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
8686
@@ -1619,9 +1619,9 @@ public abstract class LivingEntity extends Entity {
@@ -94,11 +94,11 @@ index ab02e0babf6289d64b44dc18f3f6f0bdd4b83c32..198a0cfb222f40e792a9723eb25c5148
9494
+ // entityliving.awardKillScore(this, this.deathScore, source);
9595
+ // }
9696
// Paper start - clear equipment if event is not cancelled
97-
if (this instanceof Mob mob) {
98-
java.util.Collections.fill(mob.handItems, ItemStack.EMPTY);
99-
@@ -1709,8 +1709,13 @@ public abstract class LivingEntity extends Entity {
97+
if (this instanceof Mob) {
98+
for (EquipmentSlot slot : this.clearedEquipmentSlots) {
99+
@@ -1718,8 +1718,13 @@ public abstract class LivingEntity extends Entity {
100100
this.dropCustomDeathLoot(source, i, flag);
101-
this.clearEquipmentSlots = true; // Paper
101+
this.clearEquipmentSlots = prev; // Paper
102102
}
103103
- // CraftBukkit start - Call death event
104104
- org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops); // Paper

0 commit comments

Comments
 (0)