Hi! I'm having an issue with config files being ignored after editing and restarting the client or server (Neither client, common nor server configs are working).
I'm learning how to use config files so my first file is pretty straightforward, I created a config class that looks like this:
package com.webox.myMod.config;
import net.minecraftforge.common.ForgeConfigSpec;
public class MyModCommonConfigs {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;
public static final ForgeConfigSpec.ConfigValue<Integer> CITRINE_ORE_VEINS_PER_CHUNK;
public static final ForgeConfigSpec.ConfigValue<Integer> CITRINE_ORE_VEIN_SIZE;
static {
BUILDER.push("Configs for my Mod");
CITRINE_ORE_VEINS_PER_CHUNK = BUILDER.comment("How many Citrine Ore Veins spawn per chunk!")
.define("Veins Per Chunk", 7);
CITRINE_ORE_VEIN_SIZE = BUILDER.comment("How many Citrine Ore Blocks spawn in one Vein!")
.defineInRange("Vein Size", 8, 4, 20);
BUILDER.pop();
SPEC = BUILDER.build();
}
}
And in my main class I'm using:
public MyMod()
{
// Register the setup method for modloading
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
ModItems.register(eventBus);
// Passing setup functions as parameters with :: operator
eventBus.addListener(this::commonSetup);
eventBus.addListener(this::clientSetup);
//////THIS IS WHERE I REGISTER MY CONFIG FILE ////
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, MyModCommonConfigs.SPEC);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
var bus = MinecraftForge.EVENT_BUS;
}
And finally, when I try to read a configuration I use:
System.out.println(MyModCommonConfigs.CITRINE_ORE_VEIN_SIZE.get());
This always outputs the default value no matter what the file says.
-------------------------------------
The entire process seems to work at first, since the toml file is created correctly but whenever I edit for example the vein size, and then try to access it from a place after the registration of the config file I get the default value and not the value that I've overwritten in the toml file. I've no idea what I might be doing wrong, I checked some mods on github and they all seem to be doing the same as me.
Some important remarks that may help pinpoint the problem:
- I'm not getting any errors on the console, at least that I can distinguish
- I've tried making a client config, a sever config and a common config all with the same result
- I've already tried to generate the jar file and import it into a running forge server and I got the same result, so it's not just on my dev env
- I'm using windows
- I followed this Kaupenjoe tutorial https://www.youtube.com/watch?v=QN9jq3_V-I8&list=PLKGarocXCE1Hut51TKKqZKqVZtKLZC48x&index=62&ab_channel=ModdingbyKaupenjoe
- I'm using forge 40.1.76
- I'm using minecraft 1.18.2
- Whenever I save the file, and the client or server are running I get a message from tracker that says that the file was modified and it's sending notifies
- I've explored the forum with a ton of keywords but found nothing
Thanks in advance! I Hope someone can help me