public static IInventory getInventory(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity instanceof TileEntityChest) {
Block chestBlock = world.getBlock(x, y, z);
if(world.getBlock(x - 1, y, z) == chestBlock)
return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x - 1, y, z), (IInventory)tileEntity);
if(world.getBlock(x + 1, y, z) == chestBlock)
return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x + 1, y, z));
if(world.getBlock(x, y, z - 1) == chestBlock)
return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x, y, z - 1), (IInventory)tileEntity);
if(world.getBlock(x, y, z + 1) == chestBlock)
return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x, y, z + 1));
}
return tileEntity instanceof IInventory ? (IInventory)tileEntity : null;
}