Jump to content

[solved] custom events


mnn

Recommended Posts

Is possible to have custom events? I did implement one, but it doesn't seem to be working.

 

event class: http://paste.minecraftforge.net/view/1d1907f2

event triggered: http://paste.minecraftforge.net/view/271a63a0

event handler: http://paste.minecraftforge.net/view/1036b904

handler is register in @init method:

MinecraftForge.EVENT_BUS.register(new PowerEventHandler());

 

It crashes on getting parameter-less constructor (tried even adding one, but then my event rewritten ALL other events...)

            Constructor<?> ctr = eventType.getConstructor();

2013-03-03 15:05:44 [iNFO] [sTDERR] java.lang.NoSuchMethodException: monnef.core.LightningGeneratedEvent.<init>()
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.Class.getConstructor0(Class.java:2706)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.Class.getConstructor(Class.java:1657)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at net.minecraftforge.event.EventBus.register(EventBus.java:69)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at net.minecraftforge.event.EventBus.register(EventBus.java:53)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at monnef.jaffas.power.mod_jaffas_power.load(mod_jaffas_power.java:131)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Method.java:597)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:478)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Method.java:597)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:140)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Method.java:597)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:83)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.initializeMods(Loader.java:656)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:207)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.startGame(Minecraft.java:456)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:744)
2013-03-03 15:05:44 [iNFO] [sTDERR] 	at java.lang.Thread.run(Thread.java:662)

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

problem solved. forge does some changes to all events on start using ASM library. the event is in my coremod and namespace was marked with TransformerExclusions so my event didn't get the needed tweaking after start.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.