Fixed an NPE with Buildcraft (and likely other things)

This commit is contained in:
Adubbz 2016-01-24 10:55:31 +11:00
parent fda6e74f63
commit d7d3c1656b

View file

@ -173,6 +173,10 @@ public class AchievementEventHandler
public void onBlockPlaced(BlockEvent.PlaceEvent event) public void onBlockPlaced(BlockEvent.PlaceEvent event)
{ {
ItemStack stack = event.itemInHand; ItemStack stack = event.itemInHand;
//Blocks can be placed by things other than players
if (stack != null)
{
Item item = stack.getItem(); Item item = stack.getItem();
Block block = Block.getBlockFromItem(item); Block block = Block.getBlockFromItem(item);
IBlockState state = block != null ? block.getStateFromMeta(stack.getItemDamage()) : null; IBlockState state = block != null ? block.getStateFromMeta(stack.getItemDamage()) : null;
@ -183,6 +187,7 @@ public class AchievementEventHandler
event.player.triggerAchievement(BOPAchievements.grow_sacred_oak); event.player.triggerAchievement(BOPAchievements.grow_sacred_oak);
} }
} }
}
@SubscribeEvent @SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event) public void onItemCrafted(ItemCraftedEvent event)