Skip to content

Instantly share code, notes, and snippets.

@Elements-
Created December 6, 2014 02:58
Show Gist options
  • Save Elements-/41779b3d2f20b7bc87a6 to your computer and use it in GitHub Desktop.
Save Elements-/41779b3d2f20b7bc87a6 to your computer and use it in GitHub Desktop.
Check if a chest block is a double or single then get the inventory(s)
Block b = ....
BlockFace[] sides = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for(BlockFace bf : sides) {
if(b.getRelative(bf, 1).getType() == b.getType()) {
Inventory left = ((DoubleChestInventory)((InventoryHolder)b.getState()).getInventory()).getLeftSide();
Inventory right = ((DoubleChestInventory)((InventoryHolder)b.getState()).getInventory()).getRightSide();
} else {
Chest c = (Chest) b.getState();
Inventory inv = c.getInventory();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment