Events not working somehow in 2022.3 (1.19.2)

Started by blahblahbal on

Topic category: Help with modding (Java Edition)

Last seen on 22:47, 4. Nov 2022
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Events not working somehow in 2022.3 (1.19.2)

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);
			}
		}
	}
}
Last seen on 22:47, 4. Nov 2022
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks, that worked. So…
Wed, 10/26/2022 - 00:28

Thanks, that worked. So simple of a fix haha.