Fix NPE in Crusher ritual (#739)

Also adds a utility for spawning an itemstack at a specific block location
This commit is contained in:
Nicholas Ignoffo 2016-05-13 16:50:07 -07:00
parent b684aebdaa
commit d70f423a10
2 changed files with 69 additions and 4 deletions

View file

@ -78,11 +78,14 @@ public class RitualCrushing extends Ritual
ItemStack item = new ItemStack(block, 1, meta);
ItemStack copyStack = ItemStack.copyItemStack(item);
Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN);
if (tile != null)
Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN);
else
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
if (copyStack.stackSize > 0)
{
world.spawnEntityInWorld(new EntityItem(world, pos.getX() + 0.5, pos.getY() + 2, pos.getZ() + 0.5, copyStack));
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
}
} else
{
@ -94,10 +97,17 @@ public class RitualCrushing extends Ritual
{
ItemStack copyStack = ItemStack.copyItemStack(item);
copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN);
if (tile != null)
{
copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN);
} else
{
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
continue;
}
if (copyStack != null && copyStack.stackSize > 0)
{
world.spawnEntityInWorld(new EntityItem(world, pos.getX() + 0.5, pos.getY() + 2, pos.getZ() + 0.5, copyStack));
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
}
}
}