Jump to content

[1.8] FML event bus says class FMLEvent is not an event class


jeffryfisher

Recommended Posts

In my FML event handler class, I subscribe to an event:

  @SubscribeEvent
  public void onMissing(FMLMissingMappingsEvent e)

 

In my mod's postInit, I try to register the event handler class with FML:

  public void postInit(FMLPostInitializationEvent e) {
    super.postInit (e);
    classEventBusSubs eb = new classEventBusSubs ();
    classCommonBusSubs cb = new classCommonBusSubs ();

    MinecraftForge.EVENT_BUS.register (eb);             // All of my "listeners" are in class...EventSubs,
    FMLCommonHandler.instance ().bus ().register (cb);  // So register it on every bus until events are triggered
  }

 

But FML rejects its own event as an event:

[18:44:45] [Client thread/ERROR] [FML]: The following problems were captured during this phase

[18:44:45] [Client thread/ERROR] [FML]: Caught exception from jrfmoonsensor

java.lang.IllegalArgumentException: Method public void jrfmoonsensor.classCommonBusSubs.onMissing(net.minecraftforge.fml.common.event.FMLMissingMappingsEvent) has @SubscribeEvent annotation, but takes a argument that is not an Event class net.minecraftforge.fml.common.event.FMLMissingMappingsEvent

at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:82) ~[forgeSrc-1.8-11.14.3.1450.jar:?]

at jrfmoonsensor.classSensorMod.postInit(classSensorMod.java:123) ~[bin/:?]

 

How can it not be an event class??? It's an extension of class FMLEvent! What part of "event" is not being communicated here?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

There are two types of events in Forge:

  • Events that extend
    FMLEvent

    and are handled by a method with the

    @Mod.EventHandler

    annotation in your

    @Mod

    class (e.g.

    FMLPreInitializationEvent

    ,

    FMLMissingMappingsEvent

    )

  • Events that extend
    Event

    and are handled by a method with the

    @SubscribeEvent

    annotation in a class registered on the appropriate event bus (e.g.

    BlockEvent.HarvestDropsEvent

    ,

    PlayerEvent.ItemSmeltedEvent

    )

 

You're trying to handle an

FMLEvent

like it's an

Event

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Aha... Coincidence (or confusion?) in naming. I guess I should move the handler to my main mod class (and change the annotation).

 

@statphantom: "onMissing" was just my own choice of method name (I had to call it something).

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

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.