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

Hello, I'm a fairly new modder, trying to work with 1.12 config annotations for the first time.
Right now I have a working @Config class, and working mod functionality. When the game starts, it correctly loads a boolean from the .cfg, and the mod works as it should.
However, when I change the value at runtime via mod options, it does literally nothing from what I can tell.
Here's the relevant code snippets:

@Config src

@Config(modid = Reference.MODID, name = "touchofalpha", type = Type.INSTANCE)
public class TOAConfig {
    @Comment ({
        "Classic minecraft sunset where light drops in ticks (DEFAULT: true)"
    })
    public static boolean tickingSunset = true;
}


Event handler (doesn't seem to do anything)

@SubscribeEvent
    public void configChange(ConfigChangedEvent event) {
        if (event.getModID().equals(Reference.MODID)) {
            System.out.println(Reference.MODID + ": Configuration changed");
            ConfigManager.sync(Reference.MODID, Config.Type.INSTANCE);
        }
    }


In the mod I replace the WorldProvider with a custom one, and run the following line in one of the methods:

if (TOAConfig.tickingSunset) {
	// Functional Code Here
}

 

Any help would be appreciated.
Bonus question: How do you ensure that the config option is strictly loaded from the client and not the server? Will the config loading always default to the server's cfg file? The tickingSunset option only needs to happen on the client.

Make sure to actually register the event handler.

Either you can annotate the class with @EventBusSubscriber and let it register itself automatically (but your event method has to be declared as static) or register to to MinecraftForge.EVENT_BUS

Also to answer your next question - Depends on the side where code is executed, if it's server side it's going to take data from config stored on server. However someone has to confirm that, because I'm not sure and that's how I believe it works

  • Author

I was structuring my code poorly. The event bus that I was using was registered to terraingen because of another feature I was working on, putting it on the proper bus solved it.
Thank you, I appreciate the response ?

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.