From 541753be2513fcb3bdd0e60065b9cb61286b2bf2 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 4 Mar 2023 14:57:02 -0800 Subject: [PATCH] Fix HumanEntity#drop not updating the client inventory (#6761) --- ...ity-drop-not-updating-the-client-inv.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 patches/server/0965-Fix-HumanEntity-drop-not-updating-the-client-inv.patch diff --git a/patches/server/0965-Fix-HumanEntity-drop-not-updating-the-client-inv.patch b/patches/server/0965-Fix-HumanEntity-drop-not-updating-the-client-inv.patch new file mode 100644 index 0000000000..824266cdb6 --- /dev/null +++ b/patches/server/0965-Fix-HumanEntity-drop-not-updating-the-client-inv.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sun, 10 Oct 2021 18:18:01 -0700 +Subject: [PATCH] Fix HumanEntity#drop not updating the client inv + +== AT == +public net.minecraft.server.level.ServerPlayer containerSynchronizer + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +index 11a06cd0a9cee01107941a2294fbcb493a11ab63..e54574c60c5cbc4e083c4ca11e0b7dd49bd03478 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +@@ -749,8 +749,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + // Paper end + @Override + public boolean dropItem(boolean dropAll) { +- if (!(this.getHandle() instanceof ServerPlayer)) return false; +- return ((ServerPlayer) this.getHandle()).drop(dropAll); ++ // Paper start - notify client of remote slot change ++ if (!(this.getHandle() instanceof ServerPlayer player)) return false; ++ boolean success = player.drop(dropAll); ++ if (!success) return false; ++ final net.minecraft.world.entity.player.Inventory inv = player.getInventory(); ++ final java.util.OptionalInt optionalSlot = player.containerMenu.findSlot(inv, inv.selected); ++ optionalSlot.ifPresent(slot -> player.containerSynchronizer.sendSlotChange(player.containerMenu, slot, inv.getSelected())); ++ return true; ++ // Paper end + } + + @Override