aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch
diff options
context:
space:
mode:
authorTamion <[email protected]>2023-11-04 21:20:13 +0100
committerGitHub <[email protected]>2023-11-04 13:20:13 -0700
commitbffb08c2f99a5527b7357d005cb10ba21cf048d9 (patch)
treec25ad5490b0ede8ce30bc0f23b5e0255eecc0dbc /patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch
parent6592fed511ee2ea17de9e05463579bd1923cf8aa (diff)
downloadPaper-bffb08c2f99a5527b7357d005cb10ba21cf048d9.tar.gz
Paper-bffb08c2f99a5527b7357d005cb10ba21cf048d9.zip
Deprecate Player#boostElytra (#9899)
The Paper method was chosen for deprecation because it was more restrictive in that it has an isGliding check.
Diffstat (limited to 'patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch')
-rw-r--r--patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch b/patches/server/0909-Correctly-shrink-items-during-EntityResurrectEvent.patch
new file mode 100644
index 0000000000..7b2e2d63ae
--- /dev/null
+++ b/patches/server/0909-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 e579d9cc70115a3fb3388adb309847faa1f9aaab..719f03fe96956c3fc34bbabdfa6c46bc6aca0bc1 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -1611,7 +1611,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) {