Jump to content

Recommended Posts

Posted

I'm doing my first capability, and I followed what I was referencing pretty closely albeit had to change things for my own capability. The issue comes in when running my mod, it says it needs an "addGenericListener" rather than "addListener" when the thing I'm referencing doesn't use that anywhere. I really don't how to fix the issue I'm still new to making capabilities, and I hope I explained my issue well, so any help is much appreciated.

 

Code:

Registering the Capability in the FmlCommonSetup: https://pastebin.com/5wMSrM5N

ICoolDown Interface: https://pastebin.com/jHZPwuNY

DefaultCoolDownCapability class: https://pastebin.com/pDiH3eev

CoolDownStorage class: https://pastebin.com/7e59wfuR

CoolDownProvider class: https://pastebin.com/dgCv94iG

CoolDownHandler class: https://pastebin.com/CuhG1wFR

CoolDownCapability class: https://pastebin.com/7E7Yg9Bh

Posted

Instead of subscribing event listeners like this:

MinecraftForge.EVENT_BUS.addListener(CoolDownHandler::onAttachCapabilities);
MinecraftForge.EVENT_BUS.addListener(CoolDownHandler::doCoolDown);

you can annotate the event listener class with @Mod.EventBusSubscriber()

and then anotate the event listener methods with @SubscribeEvent

 

that is not the only way to do it, but it is the one I find easier, and it should solve your listener issue

for documentation on events you can check out: https://mcforge.readthedocs.io/en/latest/events/intro/

or: https://forge.gemwire.uk/wiki/Events#Event_Listeners

Posted
1 hour ago, kiou.23 said:

you can annotate the event listener class with @Mod.EventBusSubscriber()

and then anotate the event listener methods with @SubscribeEvent

 

that is not the only way to do it, but it is the one I find easier, and it should solve your listener issue

for documentation on events you can check out: https://mcforge.readthedocs.io/en/latest/events/intro/

or: https://forge.gemwire.uk/wiki/Events#Event_Listeners

I don't even know why I didn't think of that in the first place, thank you! It worked! I was WAY overthinking it lolol

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.