Fix ClassCastException in tile entity, close #1584
This commit is contained in:
parent
fd9d9272b7
commit
42d0e641b8
6 changed files with 70 additions and 52 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue