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())
|
if (entityplayer.isSneaking())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
TileEntity tile = world.getTileEntity(i, j, k);
|
||||||
|
if (tile instanceof TileBlueprintLibrary) {
|
||||||
if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner))
|
TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary)tile;
|
||||||
|
if (!tileBlueprint.locked || entityplayer.getDisplayName().equals(tileBlueprint.owner))
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +75,9 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||||
if (!world.isRemote && entityliving instanceof EntityPlayer) {
|
if (!world.isRemote && entityliving instanceof EntityPlayer) {
|
||||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
TileEntity tile = world.getTileEntity(i, j, k);
|
||||||
tile.owner = ((EntityPlayer) entityliving).getDisplayName();
|
if (tile instanceof TileBlueprintLibrary)
|
||||||
|
((TileBlueprintLibrary)tile).owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,9 @@ public class BlockMarker extends BlockContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +119,9 @@ public class BlockMarker extends BlockContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
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);
|
dropTorchIfCantStay(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class BlockEngine extends BlockBuildCraft {
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float par7, float par8, float par9) {
|
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
|
// Drop through if the player is sneaking
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
|
@ -117,10 +117,13 @@ public class BlockEngine extends BlockBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
||||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
tile.orientation = ForgeDirection.UP;
|
if (tile instanceof TileEngine) {
|
||||||
if (!tile.isOrientationValid())
|
TileEngine engine = (TileEngine)tile;
|
||||||
tile.switchOrientation(true);
|
engine.orientation = ForgeDirection.UP;
|
||||||
|
if (!engine.isOrientationValid())
|
||||||
|
engine.switchOrientation(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,9 +134,9 @@ public class BlockEngine extends BlockBuildCraft {
|
||||||
@SuppressWarnings({"all"})
|
@SuppressWarnings({"all"})
|
||||||
@Override
|
@Override
|
||||||
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
|
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;
|
return;
|
||||||
|
|
||||||
float f = (float) i + 0.5F;
|
float f = (float) i + 0.5F;
|
||||||
|
@ -158,10 +161,10 @@ public class BlockEngine extends BlockBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
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) {
|
if (tile instanceof TileEngine) {
|
||||||
tile.checkRedstonePower();
|
((TileEngine) tile).checkRedstonePower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,9 @@ public class BlockQuarry extends BlockBuildCraft {
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
|
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
|
||||||
if (entityliving instanceof EntityPlayer) {
|
if (entityliving instanceof EntityPlayer) {
|
||||||
TileQuarry tq = (TileQuarry) world.getTileEntity(i, j, k);
|
TileEntity tile = world.getTileEntity(i, j, k);
|
||||||
tq.placedBy = (EntityPlayer) entityliving;
|
if (tile instanceof TileQuarry)
|
||||||
|
((TileQuarry) tile).placedBy = (EntityPlayer) entityliving;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,10 @@ public class BlockTank extends BlockContainer {
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
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
|
// Handle filled containers
|
||||||
if (liquid != null) {
|
if (liquid != null) {
|
||||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||||
|
@ -134,6 +136,7 @@ public class BlockTank extends BlockContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1020,9 +1020,12 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
||||||
boolean placed = world.setBlock(i, j, k, block, meta, 3);
|
boolean placed = world.setBlock(i, j, k, block, meta, 3);
|
||||||
|
|
||||||
if (placed) {
|
if (placed) {
|
||||||
TileGenericPipe tile = (TileGenericPipe) world.getTileEntity(i, j, k);
|
TileEntity tile = world.getTileEntity(i, j, k);
|
||||||
tile.initialize(pipe);
|
if (tile instanceof TileGenericPipe) {
|
||||||
tile.sendUpdateToClient();
|
TileGenericPipe tilePipe = (TileGenericPipe) tile;
|
||||||
|
tilePipe.initialize(pipe);
|
||||||
|
tilePipe.sendUpdateToClient();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return placed;
|
return placed;
|
||||||
|
|
Loading…
Reference in a new issue