Skip to content

Commit

Permalink
Fixed ingot pile NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Kittychanley committed Sep 13, 2015
1 parent 5af2ed4 commit 827435e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/Common/com/bioxx/tfc/Blocks/BlockIngotPile.java
Expand Up @@ -367,19 +367,30 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
if(!world.isRemote)
{
if(!world.isSideSolid(x, y - 1, z, ForgeDirection.UP))
if ( !world.isSideSolid(x, y - 1, z, ForgeDirection.UP) && world.getTileEntity(x, y, z) instanceof TEIngotPile)
{
if(world.getBlock(x, y - 1, z) == this && ((TEIngotPile)world.getTileEntity(x, y, z)).storage[0].getItem() == ((TEIngotPile)world.getTileEntity(x, y - 1, z)).storage[0].getItem())
TEIngotPile ingotPile = (TEIngotPile) world.getTileEntity(x, y, z);
Item ingot = ingotPile.storage[0] != null ? ingotPile.storage[0].getItem() : null;

if (world.getBlock(x, y - 1, z) == this && world.getTileEntity(x, y - 1, z) instanceof TEIngotPile)
{
combineIngotsDown(world, x, y, z);
TEIngotPile lowerPile = (TEIngotPile) world.getTileEntity(x, y - 1, z);
Item lowerIngot = lowerPile.storage[0] != null ? lowerPile.storage[0].getItem() : null;

if (ingot == lowerIngot)
combineIngotsDown(world, x, y, z);
}
else if(world.getBlock(x, y + 1, z) == this && ((TEIngotPile)world.getTileEntity(x, y, z)).storage[0].getItem() == ((TEIngotPile)world.getTileEntity(x, y + 1, z)).storage[0].getItem())
else if (world.getBlock(x, y + 1, z) == this && world.getTileEntity(x, y + 1, z) instanceof TEIngotPile)
{
combineIngotsUp(world, x, y, z);
TEIngotPile upperPile = (TEIngotPile) world.getTileEntity(x, y + 1, z);
Item upperIngot = upperPile.storage[0] != null ? upperPile.storage[0].getItem() : null;

if (ingot == upperIngot)
combineIngotsUp(world, x, y, z);
}
else
{
((TEIngotPile)world.getTileEntity(x, y, z)).ejectContents();
ingotPile.ejectContents();
world.setBlockToAir(x, y, z);
return;
}
Expand Down

0 comments on commit 827435e

Please sign in to comment.