From bd5b758a925a563b6f3e7546d634222f5e8a174a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 6 Apr 2019 00:31:19 -0400 Subject: [PATCH] Clear containers on cancelled place events It is possible for a container to be brought into the world pre-filled in place event (thanks NBT!). When the blockplacevent(s) are cancelled their blockstate is updated in OBC. This triggers them to drop their inventories. Rather than screwing with the update method which is used elsewhere, we can simply clear any inventories once we are told that a plugin intends to cancel the interaction. Fixes GH-1831 --- ...ainers-when-block-place-is-cancelled.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Spigot-Server-Patches/0436-Clear-containers-when-block-place-is-cancelled.patch diff --git a/Spigot-Server-Patches/0436-Clear-containers-when-block-place-is-cancelled.patch b/Spigot-Server-Patches/0436-Clear-containers-when-block-place-is-cancelled.patch new file mode 100644 index 0000000000..2201cc4152 --- /dev/null +++ b/Spigot-Server-Patches/0436-Clear-containers-when-block-place-is-cancelled.patch @@ -0,0 +1,26 @@ +From 86d1c4ec47db13ba21b98d644aee08f792fc20dd Mon Sep 17 00:00:00 2001 +From: Zach Brown +Date: Sat, 6 Apr 2019 00:30:32 -0400 +Subject: [PATCH] Clear containers when block place is cancelled + +Fixes GH-1831 + +diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java +index d8ebcf0a3..0ef928a2b 100644 +--- a/src/main/java/net/minecraft/server/ItemStack.java ++++ b/src/main/java/net/minecraft/server/ItemStack.java +@@ -246,6 +246,11 @@ public final class ItemStack { + for (Map.Entry e : world.capturedTileEntities.entrySet()) { + if (e.getValue() instanceof TileEntityLootable) { + ((TileEntityLootable) e.getValue()).setLootTable(null); ++ ++ // Clear containers before updating their blockstate below - Fixes GH-1831 ++ if (e.getValue() instanceof TileEntityContainer) { ++ ((TileEntityContainer) e.getValue()).clear(); ++ } + } + } + // Paper end +-- +2.21.0 +