Jump to content

Recommended Posts

Posted

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?

Posted

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)

  • Thanks 1
Posted

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.

Posted

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);
        }
    }
}

 

Posted

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.

Posted (edited)

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 by BatHeart
log file info
  • 3 months later...
Posted
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?

Posted

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

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

Posted

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 WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

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

Posted
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!

Posted (edited)

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 by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

  • 6 months later...
Posted

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.

  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } }  
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
    • When i join minecraft all ok, when i join world all working fine, but when i open indentity menu, i get this The game crashed whilst unexpected error Error: java.lang.NullPointerException: Cannot invoke "top.ribs.scguns.common.Gun$Projectile.getDamage()" because "this.projectile" is null crash report here https://paste.ee/p/0vKaf
  • Topics

×
×
  • Create New...

Important Information

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