Jump to content

[1.15.2] Config files not reading changes from any value after the first


ultra_reemun

Recommended Posts

I have added config files to my mod, however only the first value in each can be changed

 

For example one of my configs looks like this:

[dodge]
	#The time it takes for your dodge to refresh. 
	#Note that this value must be an integer (whole number) that is 2 or higher, or else things will not fire properly. 
	#Default: 4
	#Range: 2 ~ 20
	cooldown_time = 4
	#Whether or not you have to be touching the ground to dodge. 
	#Without this enabled the dodge ability can be used like a dash whilst jumping, which may be overpowered. 
	#Default: true
	requires_ground = false

And no matter what I do to requires_ground, it always will equal its default value, however I can change cooldown_time.

 

 

Here is my Config builder:

@Mod.EventBusSubscriber
public class Config {
	private static final ForgeConfigSpec.Builder server_builder = new ForgeConfigSpec.Builder();
	public static final ForgeConfigSpec server_config;
	
	private static final ForgeConfigSpec.Builder client_builder = new ForgeConfigSpec.Builder();
	public static final ForgeConfigSpec client_config;
	
	static {
		DodgeConfig.init(server_builder, client_builder);
		
		server_config = server_builder.build();
		client_config = client_builder.build();
	}
	
	public static void loadConfig(ForgeConfigSpec config, String path) {
		Dodge.LOGGER.info("Loading config: " + path);
		final CommentedFileConfig file = CommentedFileConfig.builder(new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build();
		Dodge.LOGGER.info("Built config: " + path);
		file.load();
		Dodge.LOGGER.info("Loaded config: " + path);
		config.setConfig(file);
	}
}

 

And here is my Config:

public class DodgeConfig {
	public static ForgeConfigSpec.IntValue cooldown_time;
	public static ForgeConfigSpec.BooleanValue requires_ground;
	
	public static void init(ForgeConfigSpec.Builder server, ForgeConfigSpec.Builder client) {
		server.comment("dodge config");
		
		cooldown_time = server
				.comment("The time it takes for your dodge to refresh. \nNote that this value must be an integer (whole number) that is 2 or higher, or else things will not fire properly. \nDefault: 4")
				.defineInRange("dodge.cooldown_time", 4, 2, 20);
		
		requires_ground = server
				.comment("Whether or not you have to be touching the ground to dodge. \nWithout this enabled the dodge ability can be used like a dash whilst jumping, which may be overpowered. \nDefault: true")
				.define("dodge.requires_ground", false);
	}
}

 

It is also worth noting that I have updated my DodgeConfig class and deleted my server-config.toml, however upon running minecraft server-config.toml reverts to how it was before I applied my changes.

 

I'm so confused so any help would be greatly appreciated.

 

Alternatively, if you know a better way to create a config in1.15.2 please share!

Edited by ultra_reemun
Alternate
Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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