diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2013-03-16 17:14:21 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2013-03-16 17:14:21 -0500 |
commit | 5515b0ee2b1f77b8f9083b4f087d48069d513062 (patch) | |
tree | dfbf720cfcf8e64ef338b3319542a4a058758b89 /src | |
parent | 0e60f1f7b8049a886b86be0522e6cd8f02e7b5c8 (diff) | |
download | craftbukkit-5515b0ee2b1f77b8f9083b4f087d48069d513062.tar craftbukkit-5515b0ee2b1f77b8f9083b4f087d48069d513062.tar.gz craftbukkit-5515b0ee2b1f77b8f9083b4f087d48069d513062.tar.lz craftbukkit-5515b0ee2b1f77b8f9083b4f087d48069d513062.tar.xz craftbukkit-5515b0ee2b1f77b8f9083b4f087d48069d513062.zip |
Handle double trapped chest inventory. Fixes BUKKIT-3772
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftChest.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 226be4f0..60dea439 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -32,19 +32,28 @@ public class CraftChest extends CraftBlockState implements Chest { int z = getZ(); // The logic here is basically identical to the logic in BlockChest.interact CraftInventory inventory = new CraftInventory(chest); - if (world.getBlockTypeIdAt(x - 1, y, z) == Material.CHEST.getId()) { + int id; + if (world.getBlockTypeIdAt(x, y, z) == Material.CHEST.getId()) { + id = Material.CHEST.getId(); + } else if (world.getBlockTypeIdAt(x, y, z) == Material.TRAPPED_CHEST.getId()) { + id = Material.TRAPPED_CHEST.getId(); + } else { + throw new IllegalStateException("CraftChest is not a chest but is instead " + world.getBlockAt(x, y, z)); + } + + if (world.getBlockTypeIdAt(x - 1, y, z) == id) { CraftInventory left = new CraftInventory((TileEntityChest)world.getHandle().getTileEntity(x - 1, y, z)); inventory = new CraftInventoryDoubleChest(left, inventory); } - if (world.getBlockTypeIdAt(x + 1, y, z) == Material.CHEST.getId()) { + if (world.getBlockTypeIdAt(x + 1, y, z) == id) { CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x + 1, y, z)); inventory = new CraftInventoryDoubleChest(inventory, right); } - if (world.getBlockTypeIdAt(x, y, z - 1) == Material.CHEST.getId()) { + if (world.getBlockTypeIdAt(x, y, z - 1) == id) { CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x, y, z - 1)); inventory = new CraftInventoryDoubleChest(left, inventory); } - if (world.getBlockTypeIdAt(x, y, z + 1) == Material.CHEST.getId()) { + if (world.getBlockTypeIdAt(x, y, z + 1) == id) { CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x, y, z + 1)); inventory = new CraftInventoryDoubleChest(inventory, right); } |