Fix block zap when targeting blocks that have no Item version
Closes
@@ -46,12 +46,17 @@ public class BlockZapCommand extends AbstractCommand<CommandSource> {
throw new ReturnMessageException(Nucleus.getNucleus()
.getMessageProvider().getTextMessageWithFormat("command.blockzap.alreadyair", location.getPosition().toString(), location.getExtent().getName()));
}
+
+ Text itemText = Text.of(location.getBlock().getName());
+ if (location.getBlockType().getItem().isPresent()) {
ItemStack item = ItemStack.builder()
.fromBlockState(location.getBlock())
.build();
- Text itemText = item.get(Keys.DISPLAY_NAME).orElseGet(() -> Text.of(item)).toBuilder()
+ itemText = item.get(Keys.DISPLAY_NAME).orElseGet(() -> Text.of(item)).toBuilder()
.onHover(TextActions.showItem(item.createSnapshot()))
.build();
+ }
+
if (CauseStackHelper.createFrameWithCausesWithReturn(c -> location.setBlock(BlockTypes.AIR.getDefaultState(), BlockChangeFlags.ALL), src)) {
src.sendMessage(Nucleus.getNucleus()
