Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

EventHandlers

 

During startup, Forge will call your Mod several times to let you add new blocks, items, read configuration files, and otherwise integrate itself into the game by registering your Classes in the appropriate spots.

 

Before Forge can call your Mod, it needs to know which methods to use.  This is where @EventHandler comes in.  For example - during startup Forge will go through a number of phases for all of the mods which are loaded:

PreInitialization - "Run before anything else. Read your config, create blocks, items, etc, and register them with the GameRegistry."

Initialization - "Do your mod setup. Build whatever data structures you care about. Register recipes."

PostInitialization -  "Handle interaction with other mods, complete your setup based on this.

PreInitialization is peformed for all the mods, followed by Initialization for all mods, followed by PostInitialization for all mods.  Initialising the mods in phases is particularly useful when there might be interactions between multiple mods - for example if one mod adds an extra type of wood (during PreInit), and your mod adds a recipe which uses that wood (during Init).

 

When Forge wants to tell your mod that it's time to run your PreInitialization code, it reads through your mod's code until it finds @EventHandler in front of a method, then checks the parameter definition to see if it matches the FMLPreInitializationEvent Class.  If so, it calls the method.

 

The PreInitialization, Initialization, and PostInitialization events will often need to do different things depending on whether your mod is in a CombinedClient or a DedicatedServer.  For this reason I suggest that your event handlers should just immediately call a method in the CommonProxy, see below.

 

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

    proxy.preInit();

}

 

@EventHandler

public void load(FMLInitializationEvent event) {

    proxy.load();

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event) {

    proxy.postInit();

}

 

from http://greyminecraftcoder.blogspot.com/2013/11/how-forge-starts-up-your-code.html

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.