From c30e02ea072507b489d23665b7fc2990b654171a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 21 Apr 2019 19:42:33 +0200 Subject: [PATCH] try-catch around unsafe getItem Closes #48 --- .../de/ellpeck/naturesaura/blocks/multi/Multiblocks.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java index 0bd5082a..794e0b3c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -40,8 +40,13 @@ public final class Multiblocks { (world, start, offset, pos, state, c) -> { if (state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog) return true; - ItemStack stack = state.getBlock().getItem(world, pos, state); - return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.apply(stack)); + // try-catch to prevent blocks that need to have been placed crashing here + try { + ItemStack stack = state.getBlock().getItem(world, pos, state); + return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.apply(stack)); + } catch (Exception e) { + return false; + } } ), ' ', Matcher.wildcard());