try-catch around unsafe getItem

Closes #48
This commit is contained in:
Ellpeck 2019-04-21 19:42:33 +02:00
parent 42aed4ec44
commit c30e02ea07

View file

@ -40,8 +40,13 @@ public final class Multiblocks {
(world, start, offset, pos, state, c) -> { (world, start, offset, pos, state, c) -> {
if (state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog) if (state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog)
return true; return true;
// try-catch to prevent blocks that need to have been placed crashing here
try {
ItemStack stack = state.getBlock().getItem(world, pos, state); ItemStack stack = state.getBlock().getItem(world, pos, state);
return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.apply(stack)); return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.apply(stack));
} catch (Exception e) {
return false;
}
} }
), ),
' ', Matcher.wildcard()); ' ', Matcher.wildcard());