AppleCore

AppleCore

56M Downloads

Problems with events listening

VladoCC opened this issue · 6 comments

commented

I am trying to deny exhaustion lowering if play don't have hunger and saturation, but for some reasones Forge not calling my listener
Code:
@SubscribeEvent public void onExhausted(ExhaustionEvent.Exhausted event){ if (!(event.player.getFoodStats().getSaturationLevel() > 0 && event.player.getFoodStats().getFoodLevel() > 0)){ event.deltaExhaustion = 0; event.deltaHunger = 0; event.deltaSaturation = 0; } }

Another listener (don't work too):
@SubscribeEvent public void onWork(FoodEvent.FoodEaten event){ System.out.println(event.hungerAdded); }

I am wotking in dev workspace without other mods
What am I do wrong?

commented

What Minecraft version are you working on? How are you including AppleCore in your dev environment?

commented

@squeek502 1.12.2
I did it using second method in your guide: include mod, not only api

commented

Strange. Does AppleCore show up in your mod list in game? Are you sure your event listener class is registered on the Forge EVENT_BUS?

You can find an example of a simple working setup here (it compiles against 1.12 instead of 1.12.2, though): https://github.com/squeek502/HungerInPeace/tree/1.12

commented

@squeek502
Yes, AppleCire show up in my mod list ingame, I have chat commands fron it and more.. Forge even calls your default realization of Exhausted event.

And, no, I am not sure that event listener is registered.
Code in first topic is all that I did to make this listener to work.

I checked your example and seems that my code is writen the same way as yours.

What I did wrong?

commented
commented

@squeek502 ok
I'd missed it