Howdy! ðŸ¤
I have been at this for a few days now and feel like I am at an impasse. I am happy to say blocks of the LOG tag are detected on BreakEvents.
public class ModEvents {
@Mod.EventBusSubscriber(modid = TreeFS.MODID)
public static class ForgeEvents {
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
ServerPlayer player = (ServerPlayer) event.getPlayer();
BlockState blockState = (BlockState) event.getState();
if (blockState.is(LOGS)) {
String blockStateString = blockState.toString();
player.sendSystemMessage(Component.nullToEmpty("Block broken with tag: " + blockStateString));
}
}
}
}
However, while I am able to get the blocks tag from event.getState() as a value for the blockState variable (at least I think that is what's happening), I cannot seem to implement it for .toString() .
I am sure I got some concept backwards or mixed up terminology, but, to clarify:
- I want to listen for BreakEvent.
- Get the tag of the broken block.
- if it is of tag LOGS, send the tag as a string in chat.
The chat message should read "Block broken with tag: LOGS" but instead, reads, "Block broken with tag: minecraft:tags | minecraft:logs, axis (the axis)"
I hope this explains things and you can help me.