Jump to content

[1.7.10] Custom Events/ASM


thatsimplekid

Recommended Posts

Hello all,

I am trying to implement a custom event (FML Event) into my mod (event, not handler), and have gathered that I need to use ASM for this. However, when looking at the code of other mods (Namely IC2) I cannot seem to figure out how to do this.

It would be greatly appreciated if someone could point me in the direction of an open source mod, or any documentation that would help me.

Thanks in advance,

~ ThatSimpleKid.

 

p.s. I do already have an understanding of Java Bytecode

Link to comment
Share on other sites

Show the code, you're likely doing something wrong.

 

I did this exact thing just the other week.  I created an event, set up a handler as normal, then posted it to the Forge event bus.  Things went peachy.  My only issue was that I had to modify CustomOreGeneration to do it. :P

(Which I did a PR for and had accepted!)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

EDIT: Don't worry, it now seems to work... Not sure what I did to fix it, but it's all good now... Thanks for the help anyway!  :P

 

In Main.java

 

 

...
@SubscribeEvent
   public void addTile(OxynetEvent.loadEvent event){
      System.out.println("RECEIVED EVENT");
   }

@Mod.EventHandler
    public void init(FMLInitializationEvent event) { // TileEntities, Events, Renderers
       FMLCommonHandler.instance().bus().register(this);
    }
...

 

 

 

and in OxynetEvent.java:

 

 

 


...
public class OxynetEvent {


public static class loadEvent extends Event {

}

}

 

 

 

 

and on a tile entity update method (for testing) i have:

FMLCommonHandler.instance().bus().post(new OxynetEvent.loadEvent());

Link to comment
Share on other sites

There you go then. :)

 

I do suggest moving your EventHandler functions out of your main mod class (I use a single EventHandler class that deals with all of them--with a second client-sided one for client-side stuff--other people use one-class-per-event).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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