From e4b545e0471d48879182745853c4245220fff123 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 24 Jul 2021 07:55:52 +1000 Subject: [PATCH] Only remove tile entity if block type changes By: md_5 --- .../main/java/org/bukkit/craftbukkit/block/CraftBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index cc95f43533..66f7471fb8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -183,8 +183,9 @@ public class CraftBlock implements Block { } public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) { + IBlockData old = getNMS(); // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup - if (getNMS().isTileEntity()) { // SPIGOT-3725 always remove old tile entity + if (old.isTileEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes // SPIGOT-4612: faster - just clear tile if (world instanceof net.minecraft.world.level.World) { ((net.minecraft.world.level.World) world).removeTileEntity(position); @@ -196,7 +197,6 @@ public class CraftBlock implements Block { if (applyPhysics) { return world.setTypeAndData(position, blockData, 3); } else { - IBlockData old = world.getType(position); boolean success = world.setTypeAndData(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) if (success) { world.getMinecraftWorld().notify(