Jump to content

[1.7.2] How do i use Forge events?


Recommended Posts

Hello everyone, i'm trying to update my mod to 1.7.2. In 1.6.4, i had TickHandler's, ConnectionHandler's, and other types of handlers. In 1.7, i noticed they were removed, and replaced with events. I never used Forge events separately before, so i dont realy know how to use them. Do i need to create a class implementing a "IEventHandler" type class?


Any help would be appreciated.


Thanks for reading :).


Potato's have skin. I have skin. Therefore, i am a potato.


Follow me on Twitter!


Link to comment
Share on other sites

Also, link.


One key point that I haven't yet included in that tutorial is that you need to be aware of which event bus your events are on, so you can register your handlers appropriately. You will need a separate handler for each event bus.


TickEvents are part of cpw.mods.fml.common.gameevents, and have multiple types from which to choose (ClientTickEvent, ServerTickEvent, etc.). FML Events are registered like this:

FMLCommonHandler.instance().bus().register(new YourFMLEventHandler());


Most of the other events are in net.minecraftforge.event, as well as net.minecraftforge.client.event, and these are typically registered as follows:

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

Some are registered instead to the TERRAIN_BUS, and yet others to the ORE_GEN_BUS, but most use the EVENT_BUS.


Again, it's best to have a separate handler for each type that you need, and even to split up your handler into separate ones depending on usage if you find you have a lot of events.


There doesn't seem to be any limit on the number you can register, though if you are listening to the same event in multiple handlers you will need to be extra careful that you are not conflicting with yourself.

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.

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.


  • Create New...

Important Information

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