Jump to content

Recommended Posts

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.

Posted

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

  • Thanks 1
Posted

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

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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