diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java index f06f4beb..cea6a6cf 100644 --- a/common/buildcraft/builders/BlockBlueprintLibrary.java +++ b/common/buildcraft/builders/BlockBlueprintLibrary.java @@ -43,12 +43,15 @@ public class BlockBlueprintLibrary extends BlockContainer { if (entityplayer.isSneaking()) return false; - TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); + if (tile instanceof TileBlueprintLibrary) { + TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary)tile; + if (!tileBlueprint.locked || entityplayer.getDisplayName().equals(tileBlueprint.owner)) + if (!world.isRemote) { + entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k); + } + } - if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner)) - if (!world.isRemote) { - entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k); - } return true; } @@ -72,8 +75,9 @@ public class BlockBlueprintLibrary extends BlockContainer { @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) { if (!world.isRemote && entityliving instanceof EntityPlayer) { - TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k); - tile.owner = ((EntityPlayer) entityliving).getDisplayName(); + TileEntity tile = world.getTileEntity(i, j, k); + if (tile instanceof TileBlueprintLibrary) + ((TileBlueprintLibrary)tile).owner = ((EntityPlayer) entityliving).getDisplayName(); } } diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index 7340f814..bcdc0bdd 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -90,7 +90,9 @@ public class BlockMarker extends BlockContainer { @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - ((TileMarker) world.getTileEntity(i, j, k)).tryConnection(); + TileEntity tile = world.getTileEntity(i, j, k); + if (tile instanceof TileMarker) + ((TileMarker) tile).tryConnection(); return true; } @@ -117,7 +119,9 @@ public class BlockMarker extends BlockContainer { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - ((TileMarker) world.getTileEntity(x, y, z)).updateSignals(); + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileMarker) + ((TileMarker) tile).updateSignals(); dropTorchIfCantStay(world, x, y, z); } diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index 740a6df9..c5db6446 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -95,7 +95,7 @@ public class BlockEngine extends BlockBuildCraft { @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float par7, float par8, float par9) { - TileEngine tile = (TileEngine) world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); // Drop through if the player is sneaking if (player.isSneaking()) @@ -117,10 +117,13 @@ public class BlockEngine extends BlockBuildCraft { @Override public void onPostBlockPlaced(World world, int x, int y, int z, int par5) { - TileEngine tile = (TileEngine) world.getTileEntity(x, y, z); - tile.orientation = ForgeDirection.UP; - if (!tile.isOrientationValid()) - tile.switchOrientation(true); + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileEngine) { + TileEngine engine = (TileEngine)tile; + engine.orientation = ForgeDirection.UP; + if (!engine.isOrientationValid()) + engine.switchOrientation(true); + } } @Override @@ -131,9 +134,9 @@ public class BlockEngine extends BlockBuildCraft { @SuppressWarnings({"all"}) @Override public void randomDisplayTick(World world, int i, int j, int k, Random random) { - TileEngine tile = (TileEngine) world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); - if (!tile.isBurning()) + if (tile instanceof TileEngine && !((TileEngine) tile).isBurning()) return; float f = (float) i + 0.5F; @@ -158,10 +161,10 @@ public class BlockEngine extends BlockBuildCraft { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - TileEngine tile = (TileEngine) world.getTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null) { - tile.checkRedstonePower(); + if (tile instanceof TileEngine) { + ((TileEngine) tile).checkRedstonePower(); } } diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index 520f7721..6419aec3 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -56,8 +56,9 @@ public class BlockQuarry extends BlockBuildCraft { world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1); if (entityliving instanceof EntityPlayer) { - TileQuarry tq = (TileQuarry) world.getTileEntity(i, j, k); - tq.placedBy = (EntityPlayer) entityliving; + TileEntity tile = world.getTileEntity(i, j, k); + if (tile instanceof TileQuarry) + ((TileQuarry) tile).placedBy = (EntityPlayer) entityliving; } } diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 8d480746..a0abe6ea 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -92,44 +92,47 @@ public class BlockTank extends BlockContainer { if (current != null) { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); - TileTank tank = (TileTank) world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); + if(tile instanceof TileTank) + { + TileTank tank = (TileTank)tile; + // Handle filled containers + if (liquid != null) { + int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true); - // Handle filled containers - if (liquid != null) { - int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true); + if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); + } - if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); - } + return true; - return true; - - // Handle empty containers - } else { - FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; + // Handle empty containers + } else { + FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; - if (available != null) { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); + if (available != null) { + ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); - liquid = FluidContainerRegistry.getFluidForFilledItem(filled); + liquid = FluidContainerRegistry.getFluidForFilledItem(filled); - if (liquid != null) { - if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { - if (current.stackSize > 1) { - if (!entityplayer.inventory.addItemStackToInventory(filled)) - return false; - else { + if (liquid != null) { + if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { + if (current.stackSize > 1) { + if (!entityplayer.inventory.addItemStackToInventory(filled)) + return false; + else { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); + } + } else { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled); } - } else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled); } + + tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); + + return true; } - - tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); - - return true; } } } diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 582e4230..b78508c5 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -1020,9 +1020,12 @@ public class BlockGenericPipe extends BlockBuildCraft { boolean placed = world.setBlock(i, j, k, block, meta, 3); if (placed) { - TileGenericPipe tile = (TileGenericPipe) world.getTileEntity(i, j, k); - tile.initialize(pipe); - tile.sendUpdateToClient(); + TileEntity tile = world.getTileEntity(i, j, k); + if (tile instanceof TileGenericPipe) { + TileGenericPipe tilePipe = (TileGenericPipe) tile; + tilePipe.initialize(pipe); + tilePipe.sendUpdateToClient(); + } } return placed;