From 1abad1ff373ea644ebbf4471623e8b150e63fd29 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 6 Apr 2019 10:23:05 -0400 Subject: [PATCH] Improve Cancelled Block Place Tile Entity discardment We bandaided this logic on a case by case basis before with Loot Tables and Chests, but that is not the correct fix. Ultimately we just needed to clear out the captured tile entity list so that the update calls did not process the tile entity that is no longer even valid. This solution will ensure ALL placed tile entities data is ignored and not just the few cases we previously had filters for. --- ...ow-chests-to-be-placed-with-NBT-data.patch | 14 +++-------- ...ainers-when-block-place-is-cancelled.patch | 24 ------------------- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 Spigot-Server-Patches/Clear-containers-when-block-place-is-cancelled.patch diff --git a/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch b/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch index d260888dd..8b8833f92 100644 --- a/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch +++ b/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch @@ -5,27 +5,19 @@ Subject: [PATCH] Allow chests to be placed with NBT data diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java -index f34ac392e..d8ebcf0a3 100644 +index f34ac392e1..eb130c0121 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -0,0 +0,0 @@ public final class ItemStack { enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed placeEvent.getPlayer().updateInventory(); -+ -+ // Paper start -+ for (Map.Entry e : world.capturedTileEntities.entrySet()) { -+ if (e.getValue() instanceof TileEntityLootable) { -+ ((TileEntityLootable) e.getValue()).setLootTable(null); -+ } -+ } -+ // Paper end -+ ++ world.capturedTileEntities.clear(); // Paper - clear out tile entities as chests and such will pop loot // revert back all captured blocks for (BlockState blockstate : blocks) { blockstate.update(true, false); diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java -index c46b761cc..2e0f782f6 100644 +index c46b761cc5..2e0f782f65 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic diff --git a/Spigot-Server-Patches/Clear-containers-when-block-place-is-cancelled.patch b/Spigot-Server-Patches/Clear-containers-when-block-place-is-cancelled.patch deleted file mode 100644 index de5af2942..000000000 --- a/Spigot-Server-Patches/Clear-containers-when-block-place-is-cancelled.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zach Brown <1254957+zachbr@users.noreply.github.com> -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 -@@ -0,0 +0,0 @@ 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 --- \ No newline at end of file