From d7d3c1656bf211d5b15d4463b1a6676350defab2 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 24 Jan 2016 10:55:31 +1100 Subject: [PATCH] Fixed an NPE with Buildcraft (and likely other things) --- .../common/handler/AchievementEventHandler.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/biomesoplenty/common/handler/AchievementEventHandler.java b/src/main/java/biomesoplenty/common/handler/AchievementEventHandler.java index 4fc48389d..bbe3f07f2 100644 --- a/src/main/java/biomesoplenty/common/handler/AchievementEventHandler.java +++ b/src/main/java/biomesoplenty/common/handler/AchievementEventHandler.java @@ -173,14 +173,19 @@ public class AchievementEventHandler public void onBlockPlaced(BlockEvent.PlaceEvent event) { ItemStack stack = event.itemInHand; - Item item = stack.getItem(); - Block block = Block.getBlockFromItem(item); - IBlockState state = block != null ? block.getStateFromMeta(stack.getItemDamage()) : null; - //Yggdrasil - if (state == BlockBOPSapling.paging.getVariantState(BOPTrees.SACRED_OAK)) + //Blocks can be placed by things other than players + if (stack != null) { - event.player.triggerAchievement(BOPAchievements.grow_sacred_oak); + Item item = stack.getItem(); + Block block = Block.getBlockFromItem(item); + IBlockState state = block != null ? block.getStateFromMeta(stack.getItemDamage()) : null; + + //Yggdrasil + if (state == BlockBOPSapling.paging.getVariantState(BOPTrees.SACRED_OAK)) + { + event.player.triggerAchievement(BOPAchievements.grow_sacred_oak); + } } }