From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Sat, 25 Jun 2016 23:55:56 -0500 Subject: [PATCH] Don't try and fix TileEntities as they are removed Currently, CraftBukkit tries to fix TEs that do not match the present block at the location. This is normally good, however, this same fixer runs when the TE removal functions go through to remove a TE after its block has been changed. So a block will be changed, the server will attempt to remove the TE present, but will then get caught up in CB's overzealous TE fixer. That fixer checks the block against the TE present, and throws a fit because it doesn't match. Which is why we're removing it in the first place. The 'fix' to this issue is to skip the fixer entirely when we're removing the TE, as it shouldn't ever need to run then anyway, we're removing it. diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/BlockChest.java +++ b/src/main/java/net/minecraft/server/BlockChest.java @@ -0,0 +0,0 @@ public class BlockChest extends BlockTileEntity { } public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { - TileEntity tileentity = world.getTileEntity(blockposition); + TileEntity tileentity = world.getTileEntity(blockposition, true); // Paper - This is being removed, don't fix if (tileentity instanceof IInventory) { InventoryUtils.dropInventory(world, blockposition, (IInventory) tileentity); diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -0,0 +0,0 @@ public class BlockDispenser extends BlockTileEntity { } public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { - TileEntity tileentity = world.getTileEntity(blockposition); + TileEntity tileentity = world.getTileEntity(blockposition, true); // Paper - This is being removed, don't fix if (tileentity instanceof TileEntityDispenser) { InventoryUtils.dropInventory(world, blockposition, (TileEntityDispenser) tileentity); diff --git a/src/main/java/net/minecraft/server/BlockFurnace.java b/src/main/java/net/minecraft/server/BlockFurnace.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/BlockFurnace.java +++ b/src/main/java/net/minecraft/server/BlockFurnace.java @@ -0,0 +0,0 @@ public class BlockFurnace extends BlockTileEntity { public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { if (!BlockFurnace.c) { - TileEntity tileentity = world.getTileEntity(blockposition); + TileEntity tileentity = world.getTileEntity(blockposition, true); // Paper - This is being removed, don't fix if (tileentity instanceof TileEntityFurnace) { InventoryUtils.dropInventory(world, blockposition, (TileEntityFurnace) tileentity); diff --git a/src/main/java/net/minecraft/server/BlockSkull.java b/src/main/java/net/minecraft/server/BlockSkull.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/BlockSkull.java +++ b/src/main/java/net/minecraft/server/BlockSkull.java @@ -0,0 +0,0 @@ public class BlockSkull extends BlockTileEntity { // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { if (false) { // CraftBukkit end - TileEntity tileentity = world.getTileEntity(blockposition); + TileEntity tileentity = world.getTileEntity(blockposition, true); // Paper - This is being removed, don't fix if (tileentity instanceof TileEntitySkull) { TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { } public Map capturedTileEntities = Maps.newHashMap(); + // Paper start - Add additional param so we can ignore fixing on removals @Nullable public TileEntity getTileEntity(BlockPosition blockposition) { + return getTileEntity(blockposition, false); + } + + public TileEntity getTileEntity(BlockPosition blockposition, boolean isRemoving) { + // Paper end if (blockposition.isInvalidYLocation()) { // Paper return null; } else { @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { } public void s(BlockPosition blockposition) { - TileEntity tileentity = this.getTileEntity(blockposition); + TileEntity tileentity = this.getTileEntity(blockposition, true); // Paper - This is being removed, don't fix if (tileentity != null && this.M) { tileentity.y(); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { // CraftBukkit start @Override + // Paper start - Add additional param so we can ignore fixing on removals public TileEntity getTileEntity(BlockPosition pos) { - TileEntity result = super.getTileEntity(pos); + return getTileEntity(pos, false); + } + + @Override + public TileEntity getTileEntity(BlockPosition pos, boolean isRemoving) { + TileEntity result = super.getTileEntity(pos, isRemoving); + if (isRemoving) return result; + // Paper end Block type = getType(pos).getBlock(); if (type == Blocks.CHEST || type == Blocks.TRAPPED_CHEST) { // Spigot --