From e62905aabe92ca3c8646285b59037e688731a18d Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 25 Sep 2023 07:47:22 +1000 Subject: [PATCH] SPIGOT-7490: Fix entity equipment updates --- .../server/level/EntityTrackerEntry.patch | 2 +- .../minecraft/world/entity/EntityLiving.patch | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 5f735d50f7f4..7f8f46b1df6e 100644 --- a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -117,7 +117,7 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } -+ ((EntityLiving) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending ++ ((EntityLiving) this.entity).detectEquipmentUpdatesPublic(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending + } + + // CraftBukkit start - MC-109346: Fix for nonsensical head yaw diff --git a/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 00cef3d7746d..23588556d645 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -536,7 +536,7 @@ + return i; + } else { + return 0; -+ } + } + } + // CraftBukkit end + @@ -545,7 +545,7 @@ + if (true && !(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time + EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop); + this.expToDrop = 0; - } ++ } + // CraftBukkit end } @@ -726,7 +726,7 @@ + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + this.hurtArmor(damagesource, armorDamage); + } - ++ + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + this.level().broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound @@ -741,7 +741,7 @@ + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; -+ + + if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) { + ((EntityHuman) this).awardStat(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); + } @@ -839,6 +839,24 @@ this.setSharedFlag(7, false); } } else { +@@ -2443,7 +2891,7 @@ + } + } + +- this.detectEquipmentUpdates(); ++ this.detectEquipmentUpdatesPublic(); // CraftBukkit + if (this.tickCount % 20 == 0) { + this.getCombatTracker().recheckStatus(); + } +@@ -2540,7 +2988,7 @@ + this.refreshDirtyAttributes(); + } + +- public void detectEquipmentUpdates() { ++ public void detectEquipmentUpdatesPublic() { // CraftBukkit + Map map = this.collectEquipmentChanges(); + + if (map != null) { @@ -2837,6 +3285,7 @@ }