Skip to content

Commit

Permalink
Failing to calculate an ItemStack should result in dropping nothing, …
Browse files Browse the repository at this point in the history
…not crashing. ( Fixes #272 )
  • Loading branch information
AlgorithmX2 committed May 23, 2017
1 parent 8d950b1 commit 0aa7004
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/mod/chiselsandbits/chiseledblock/BlockChiseled.java
Expand Up @@ -370,7 +370,7 @@ public void dropBlockAsItemWithChance(
{
try
{
spawnAsEntity( worldIn, pos, getTileEntity( worldIn, pos ).getItemStack( null ) );
spawnItemEntity( worldIn, pos, getTileEntity( worldIn, pos ).getItemStack( null ) );
}
catch ( final ExceptionNoTileEntity e )
{
Expand All @@ -389,8 +389,7 @@ public void harvestBlock(
{
try
{
spawnAsEntity( worldIn, pos, getTileEntity( te ).getItemStack( player ) );

spawnItemEntity( worldIn, pos, getTileEntity( te ).getItemStack( player ) );
}
catch ( final ExceptionNoTileEntity e )
{
Expand All @@ -399,6 +398,17 @@ public void harvestBlock(
}
}

private void spawnItemEntity(
World worldIn,
BlockPos pos,
ItemStack itemStack )
{
if ( itemStack != null )
{
spawnAsEntity( worldIn, pos, itemStack );
}
}

@Override
public List<ItemStack> getDrops(
final IBlockAccess world,
Expand Down

0 comments on commit 0aa7004

Please sign in to comment.