blockStateis null if it can not be placed

This commit is contained in:
Frank Bauer 2021-06-29 23:32:31 +02:00
parent befdd2c10a
commit 1ebb93d7ab

View file

@ -34,7 +34,9 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
BlockState blockState = super.getPlacementState(blockPlaceContext); BlockState blockState = super.getPlacementState(blockPlaceContext);
ItemStack stack = blockPlaceContext.getItemInHand(); ItemStack stack = blockPlaceContext.getItemInHand();
int destruction = stack.getOrCreateTag().getInt(DESTRUCTION); int destruction = stack.getOrCreateTag().getInt(DESTRUCTION);
blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction); if (blockState != null) {
blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction);
}
return blockState; return blockState;
} }