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

Posted

Hey fellow modders,

 

I followed Forge's example and setup configuration files and the associated gui menu's that appear after clicking my mod's config button by extending GuiConfig and all that good stuff.

 

However, I'm getting stuck with my event handler that saves my configuration file not receiving the onConfigChangedEvent even though I (supposedly) registered it to the EVENT_BUS.

 

My code is (generally) as follows:

public class ConfigEventHandler {
    @SubscribeEvent(priority=EventPriority.NORMAL)
    public void onEvent(OnConfigChangedEvent event)
    {
    	System.out.println("Config Changed Event Fired!");
        if (MyMod.MODID.equals(event.modID) && !event.isWorldRunning)
        {
            if (Configuration.CATEGORY_GENERAL.equals(event.configID))
            {
                StartupCommon.syncConfig(false); //my version of syncConfig is almost identical to Forge's
            }
            else if ("miscConfig".equals(event.configID))
            {
                //update miscConfiguration file
            }
        }
    }
}

 

InitCommon is similar to GreyGhost's implementation in MinecraftByExample (runs during Init phase in both clients and dedicated servers):

public static void initCommon() {
	//register the save config handler to EVENT_BUS bus
	System.out.println("Registering event handlers...");
	MinecraftForge.EVENT_BUS.register(new ConfigEventHandler());
}

 

I'm not sure if my mod's container needs to implement registerBus like ForgeModContainer does. And if it needs to, I am not sure how to override methods of my mod's container since forge creates the container for me.

OnConfigChangedEvent is fired on FML's event bus, not Forge's. Create a public static instance of ConfigEventHandler, and register it with FMLCommonHandler.instance().bus().register(configEventHandler).

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

 

Follow me on Twitter!

http://www.twitter.com/I_Mod_Minecraft

  • Author

Perfect, everything works now! In the future I should probably check which package the event is in before deciding on the correct bus. Thanks!  :)

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.