Posted August 10, 20178 yr Hello, I have made a config using the annotation. It displays fine but the values dont seem to actually save nor do they change. Here is my config class: package net.drok.poverhaul; import net.minecraftforge.common.config.Config; @Config(modid = POHMod.MODID) public class ModConfig { public static Tools tools = new Tools(); public static class Tools { @Config.Comment("Defines whether or not to use a more realistic harvest system.") public boolean fixedHarvest = true; @Config.Comment("The speed scaling of tools with a quality of 0") public double minToolScaling = 0.3; @Config.Comment("The speed scaling of tools with a quality of 100") public double maxToolScaling = 1.2; } } And I am using ModConfig.tools.value to access the values. As i said i can change them in the gui but the value is always the default value when i print it to the console.
August 10, 20178 yr I don't know much about configs, but I believe you need to synchronize your config with ConfigManager#sync(). At least, if you're talking about GUI changes, this is definitely the case. Read below:
August 10, 20178 yr Author 14 minutes ago, MrBendelScrolls said: I don't know much about configs, but I believe you need to synchronize your config with ConfigManager#sync(). At least, if you're talking about GUI changes, this is definitely the case. Read below: Where would i call the sync function? Is there an event?
August 10, 20178 yr You should call it where you changes the field. Or anywhere you want to save your changes. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
August 11, 20178 yr I will make it simple. To save changes made from GUI, subscribe to ConfigChangedEvent.OnConfigChangedEvent. Check if event's modid is the modid of your mod, then call ConfigManager#sync(). I don't have access to sources right now, but the code looks like this: @EventBusSubscriber public class ConfigEventHandler { /* I prefer to make it inner class of my config class, but it doesn't have to be, it just needs to be registered. Read docs about events if you don't understand. */ @SubscribeEvent public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.getModid().equals(modid) { ConfigManager.sync(modid, Config.Type.INSTANCE); } } } I believe,ConfigManager#sync() also saves changes made to fields to your config file, but as I said, I don't know much about configs .
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.