Started by
blahblahbal
on
Topic category: Help with Minecraft modding (Java Edition)
Alright, so I've ported most of my mod to 1.19, but a couple things seem to not work, and they have to do with events. I have tried everything to be quite honest. It just doesn't seem to run at all, and I have no clue why. (I have also tried event.setCanceled(true); instead of setNewSpeed(0F);)
Here is the code for one of my custom elements (it's supposed to prevent breaking of a block unless the player is holding a specific item in their main hand to mine with):
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class BreakSpeedEvents
{
@SubscribeEvent
public void getBreakSpeed(BreakSpeed event)
{
Player entity = event.getEntity();
if (entity.getMainHandItem() != null)
{
if (event.getState().getBlock() == BlahmodModBlocks.LUMITE_ORE.get() && !(entity.getMainHandItem().getItem() == BlahmodModItems.BEDROCK_PICKAXE.get() || entity.getMainHandItem().getItem() == BlahmodModItems.LUMITE_PICKAXE.get()))
{
event.setNewSpeed(0F);
}
}
}
}
Your method needs to be static for this approach you are using.
Thanks, that worked. So simple of a fix haha.