From 65052c8a59ecfdf927e5bbfe4257c7a7c90e55e4 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Sun, 18 Sep 2011 00:03:58 +0100 Subject: [PATCH] Workaround for crash when chests mix up with furnaces - need to investigate cause --- .../net/minecraft/server/TileEntityChest.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java index e5761b05c5..4e03b29599 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -119,19 +119,19 @@ public class TileEntityChest extends TileEntity implements IInventory { this.d = null; this.e = null; if (this.world.getTypeId(this.x - 1, this.y, this.z) == Block.CHEST.id) { - this.d = (TileEntityChest) this.world.getTileEntity(this.x - 1, this.y, this.z); + this.d = getTileEntity(this.x - 1, this.y, this.z); // CraftBukkit } if (this.world.getTypeId(this.x + 1, this.y, this.z) == Block.CHEST.id) { - this.c = (TileEntityChest) this.world.getTileEntity(this.x + 1, this.y, this.z); + this.c = getTileEntity(this.x + 1, this.y, this.z); // CraftBukkit } if (this.world.getTypeId(this.x, this.y, this.z - 1) == Block.CHEST.id) { - this.b = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z - 1); + this.b = getTileEntity(this.x, this.y, this.z - 1); // CraftBukkit } if (this.world.getTypeId(this.x, this.y, this.z + 1) == Block.CHEST.id) { - this.e = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z + 1); + this.e = getTileEntity(this.x, this.y, this.z + 1); // CraftBukkit } if (this.b != null) { @@ -152,6 +152,19 @@ public class TileEntityChest extends TileEntity implements IInventory { } } + // CraftBukkit start + private TileEntityChest getTileEntity(int x, int y, int z) { + TileEntity entity = this.world.getTileEntity(x, y, z); + + if (entity instanceof TileEntityChest) { + return (TileEntityChest)entity; + } else { + world.getServer().getLogger().severe("Block at " + x + "," + y + "," + z + " is a chest but has a " + entity.getClass().getName()); + return null; + } + } + // CraftBukkit end + public void h_() { super.h_(); this.h();