Topic category: Help with modding (Java Edition)
I'm trying to create a mod that puts the player in difficulty when he tries to break a block of wood and if he doesn't have an ax he gets nothing.
I wrote this code but it gives me error
@Mod.EventBusSubscriber
public class Woodprocedure {
@SubscribeEvent
public static void harvestCheck(PlayerEvent.BreakSpeed event) {
BlockState block = event.getState();
// Check if the block is a trunk (log)
if (block.getBlock().getRegistryName().getPath().contains("log")) {
PlayerEntity player = event.getPlayer();
ItemStack item = player.getHeldItemMainhand();
// Check if the object in your hand is not an axe
if (!(item.getItem() instanceof AxeItem)) {
event.setCanceled(true);
}
}
}
}
This can be achieved using procedures so you may not need to have actual code for this
I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei