Using Forge events
With LabyMod we're delivering a selection of Forge events you can use to develop LabyMod addons.
If you're interested in more than just this selection of Forge events, you can add your required method calls by manipulating the bytecode via ASM. Alternatively you can create an issue in our GitHub issue tracker where you explain which event you need.
Forge events you can use:
FOVUpdateEvent - Called when the player's fov gets updated
GuiOpenEvent - Called when a new GUI is being opened
GuiScreenEvent$DrawScreenEvent$Post - Called after any GUI has been drawn
RenderWorldLastEvent - Called after the world has been rendered
InputEvent$KeyInputEvent - Called when a key is pressed
InputEvent$MouseInputEvent - Called when a mouse button is clicked
TickEvent$ClientTickEvent - Called after every Minecraft tick
TickEvent$RenderTickEvent - Called before every render-tick
Creating event listeners
Your listener-method's first parameter should be a type of the event you want to use (e.g. TickEvent$ClientTickEvent). The method should also be annotated by the SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent) class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Registering event listeners
You should register the event listeners using LabyModAddon#getApi()#registerForgeListener( Object listener ) in your LabyModAddon#onEnable() method.
1 2 3 4