Posted February 21, 20196 yr I've been trying to set up my mod config using the new ForgeConfigSpec calls. For reference, I have been following the way it is done in ForgeConfig, for Forge's own config. I am still puzzled because I can't get it to launch without errors. Does anyone have a working example of this for 1.13.2 - ForgeConfigSpec - that I can examine and learn from?
February 22, 20196 yr My modConfig: package de.madone.nimox.config; import net.minecraftforge.common.ForgeConfigSpec; public class ModConfig { private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); public static final General GENERAL = new General(BUILDER); public static final ForgeConfigSpec spec = BUILDER.build(); public static class General { public final ForgeConfigSpec.ConfigValue<Boolean> ModEnabled; public final ForgeConfigSpec.ConfigValue<Integer> TorchDistance; public General(ForgeConfigSpec.Builder builder) { builder.push("General"); ModEnabled = builder .comment("Enables/Disables the whole Mod [false/true|default:true]") .translation("enable.ocdtorcher.config") .define("enableMod", true); TorchDistance = builder .comment("sets the Reach of the Torcher [0..50|default:20]") .translation("distance.ocdtorcher.config") .defineInRange("TorcherDistance", 20, 0,50); builder.pop(); } } } Main-Class-Constructor: // load Configfile ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, de.madone.nimox.config.ModConfig.spec); But it's not available at registration time. (NPE)
February 22, 20196 yr Author Thanks for this LTNightshade! I had found another example in the mean time, but all examples are very useful. I have actually got mine working now, but it appears that the Config button on the Mods screen is not yet implemented (It doesn't work for the Forge internal mod either). However, I can edit my configuration toml file manually and my mod picks up the changes, which felt like a great leap forward! The one problem I've had to workaround is that my config was split into 3 subsections. I don't know how to do this in the new ForgeConfigSpec implementation without getting crashes. So for the moment I've just used the one config section.
February 22, 20196 yr Where's the problem ? public class ModConfig { private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); public static final General GENERAL = new General(BUILDER); public static final Section2 SECTION_2 = new Section2(BUILDER); public static final ForgeConfigSpec spec = BUILDER.build(); public static class General { public final ForgeConfigSpec.ConfigValue<Boolean> ModEnabled; public final ForgeConfigSpec.ConfigValue<Integer> TorchDistance; public General(ForgeConfigSpec.Builder builder) { builder.push("General"); ModEnabled = builder .comment("Enables/Disables the whole Mod [false/true|default:true]") .translation("enable.ocdtorcher.config") .define("enableMod", true); TorchDistance = builder .comment("sets the Reach of the Torcher [0..50|default:20]") .translation("distance.ocdtorcher.config") .defineInRange("TorcherDistance", 20, 0,50); builder.pop(); } } public static class Section2 { public final ForgeConfigSpec.ConfigValue<Boolean> BoolVal2; public Section2(ForgeConfigSpec.Builder builder) { builder.push("section2"); BoolVal2 = builder .comment("Enables/Disables whatever [false/true|default:true]") .translation("enable.sec2.ocdtorcher.config") .define("ensec2", true); } } }
February 22, 20196 yr Author Difficult to describe without screenshots, but I have too many options to put easily on one screen, so in all of my previous versions I split them up into 3 screens. So when you click on Config the first thing you see is the choice of 3: "Coordinates Options" "Timer Options" or "Infopanel Options". Clicking on "Coordinates Options" brings up a page of just those options, etc. I implemented all this in 1.12 using the @config annotation system, which allowed this kind of structure (outer-level config, 3x inner-level configs) I just don't see whether the new ForgeConfigSpec system permits you to do this.
February 22, 20196 yr Author Oh. I see your example. Well, the problem I get when doing that is I get a run time error saying there is a conflict between my mod's config and itself. It's as though it sees each of them as my mod, and doesn't allow duplicates of the same mod to have config. The log file shows the error as: [22Feb2019 14:20:01.027] [modloading-worker-1/ERROR] [net.minecraftforge.fml.config.ConfigTracker/CONFIG]: Detected config file conflict coordinatesplusmod-client.toml between coordinatesplusmod and coordinatesplusmod [22Feb2019 14:20:01.028] [modloading-worker-1/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Failed to create mod instance. ModID: coordinatesplusmod, class battys.coordinatesplusmod.BattyBaseUI Edited February 22, 20196 yr by BatHeart log file info
June 20, 20196 yr On 2/22/2019 at 12:55 PM, BatHeart said: Thanks for this LTNightshade! I had found another example in the mean time, but all examples are very useful. I have actually got mine working now, but it appears that the Config button on the Mods screen is not yet implemented (It doesn't work for the Forge internal mod either). However, I can edit my configuration toml file manually and my mod picks up the changes, which felt like a great leap forward! The one problem I've had to workaround is that my config was split into 3 subsections. I don't know how to do this in the new ForgeConfigSpec implementation without getting crashes. So for the moment I've just used the one config section. How did you update the changes in game?
June 22, 20196 yr https://github.com/Cadiboo/Example-Mod/blob/216b1e05118261ce628990023a229173d097d72e/src/main/java/io/github/cadiboo/examplemod/config/ConfigHelper.java#L39-L42 Please not that config saving is asynchronous and it happens on another thread About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
June 22, 20196 yr Author On 6/20/2019 at 2:24 PM, Vistaf said: How did you update the changes in game? I couldn't update them in game. As I say in that post, I don't think the in-game config button is implemented yet, so I just updated the toml file manually. However, since I made that post, I've been shown that the Forge config really wasn't working at that point. Hopefully it's now better, and I'll have another go at including it. I've had to tell people that basically there is no configuration possible of the 1.13 version of my mod.
June 23, 20196 yr It’s not implemented yet because cpw has much larger priorities and not much free time. Massive amounts of the config GUI code need to be rewritten About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
June 23, 20196 yr Author 9 hours ago, Cadiboo said: It’s not implemented yet because cpw has much larger priorities and not much free time. Massive amounts of the config GUI code need to be rewritten Thanks. I'd pretty much worked that out back in Feb. I'm prepared to wait. I wasn't going to say anything more, but then I saw the question Vistaf was asking me, and had to clarify.
June 28, 20196 yr On 6/23/2019 at 1:34 AM, Cadiboo said: It’s not implemented yet because cpw has much larger priorities and not much free time. Massive amounts of the config GUI code need to be rewritten With your example, do the config values change during runtime? (i.e you don't have to reload the minecraft client in order to get the changes made directly to the config in say a text editor?) and if they do, how? Like which values should i be getting, ive tried like ExampleModConfig.clientBoolean but that doesn't update. Thanks!
June 29, 20196 yr In my example, ConfigHelper.setAndSave saves a value. To use it, you need a ModConfig, a path for the value you want to set, and an actual value to set. Config saving is done async, so the changes you make will be applied usually within the next 10 seconds. Examples of setting a value https://github.com/Cadiboo/NoCubes/blob/6c28c100c61e8c629d33a83ba87dbaa41f7f7662/src/main/java/io/github/cadiboo/nocubes/config/ConfigHelper.java#L392-L407 Examples of setting a value + updating the baked value (unclean code, but it gets the job done until there’s a way to force a non-async save+load) https://github.com/Cadiboo/NoCubes/blob/91dcad05ec74621a4af31c0cc5e06ebbb3b094e2/src/main/java/io/github/cadiboo/nocubes/client/ClientEventSubscriber.java#L86-L104 Edit: I now use this method (which includes some hacks to replicate the functionality that my PR adds) Edited January 22, 20205 yr by Cadiboo About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
January 22, 20205 yr Has the GUI config button been implemented? (Jan 22, 2020) On Minecraft 1.15.2 Forge 30.0.41, all config buttons are disabled, including the forge one. When will this feature be available? Should I start migrating to 1.15.2 or stay at 1.12.2? My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution https://github.com/RoyalAliceAcademyOfSciences/SimElectricity
January 22, 20205 yr Yep, PR: https://github.com/MinecraftForge/MinecraftForge/pull/6421 I’m currently working on the Forge docs for the config system, here’s my tutorial on them in the meantime. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
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.