aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-12-05 11:18:29 +0100
committerNassim Jahnke <[email protected]>2024-12-05 12:20:56 +0100
commite4e24f3335609b38f460ced71d18babcf11bf9cb (patch)
tree51880d664b3444ce26d6f8cdeb3b8219e5616fca /patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch
parentc54c062e6ff742445bf7749c84106ca67090172d (diff)
downloadPaper-e4e24f3335609b38f460ced71d18babcf11bf9cb.tar.gz
Paper-e4e24f3335609b38f460ced71d18babcf11bf9cb.zip
Move around patches again
Diffstat (limited to 'patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch')
-rw-r--r--patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch b/patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch
new file mode 100644
index 0000000000..f16e8a752f
--- /dev/null
+++ b/patches/server/0776-Correctly-shrink-items-during-EntityResurrectEvent.patch
@@ -0,0 +1,36 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Bjarne Koll <[email protected]>
+Date: Tue, 10 Jan 2023 21:06:42 +0100
+Subject: [PATCH] Correctly shrink items during EntityResurrectEvent
+
+The EntityResurrectEvent logic is supposed to locate a totem of undying
+in any of the interaction slots of the player inventory and then, if the
+called EntityResurrectEvent is not cancelled, shrink that item by 1,
+usually reducing it to zero.
+
+For this, the logic iterates over the items in the interaction slots and
+breaks out the loop if a totem of undying was found.
+However, even if no totem of undying was found, the iteration item stack
+variable remains as a refernce to the last interaction slot probed.
+
+Plugins uncancelling a EntityResurrectEvent, which is published
+pre-cancelled to listeners if no totem of undying could be found,
+would hence cause the server logic to shrink completely unrelated items
+found in, at the writing of this patch, the players off hand slot.
+
+This patch corrects this behaviour by only shrinking the item if a totem
+of undying was found and the event was called uncancelled.
+
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index cdd94eb9b82bb22505461ae135d12914d7446b00..1c67dafa4a54513d2f8febd13124ea5c976b313e 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -1683,7 +1683,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+- if (!itemstack1.isEmpty()) {
++ if (!itemstack1.isEmpty() && itemstack != null) { // Paper - only reduce item if actual totem was found
+ itemstack1.shrink(1);
+ }
+ if (itemstack != null && this instanceof ServerPlayer) {