Jump to content

Recommended Posts

Posted (edited)

I've tried everything I can think of at the moment to register a configuration file for one of my mods in 1.15. I've looked at a bunch of source code from other mods to see what I am doing wrong, but I can't tell what's different.

 

I run this code during the FMLCommonSetupEvent:

ModLoadingContext.get().registerConfig(Type.COMMON, commonSpecPair.getRight());

which references this:

private static final Pair<Common, ForgeConfigSpec> commonSpecPair = new Builder().configure(Common::new);

and creates an instance of:

private static final class Common {
		private final DoubleValue heightWeight, metallicityWeight;
		private final BooleanValue realisticLightning, spawnFire;

		public Common(Builder builder) {
			builder.comment("Common settings").push("General");

			heightWeight = builder.comment("TODO").defineInRange("Height Weight", .5, 0, 1);
			metallicityWeight = builder.comment("TODO").defineInRange("Metallicity Weight", .5, 0, 1);
			realisticLightning = builder.comment("TODO").define("Realistic Lightning", true);
			spawnFire = builder.comment("TODO").define("Spawn Fire", true);

			builder.pop();
		}
	}

 

However, the configuration file is never created and no log messages are given that could give me a hint as to what is going wrong.

 

Update: I've only found one workaround that makes it generate correctly. I don't think it's the proper way to do this, so I'm hoping for a better method. I just have to run this after registering the config.

ConfigTracker.INSTANCE.loadConfigs(Type.COMMON, FMLPaths.CONFIGDIR.get());

 

Edited by Caffeinated Pinkie
Posted (edited)

Put your registerConfig call in your mod constructor.

Mod event order:

  • Mod construction (move yourregisterConfig here)
  • RegistryEvent.Register<T>
  • Config loading
  • Common setup (your registerConfig was in here)
  • Sided setup
  • ...

See ModLoader.loadMods, line 152 for source.

Edited by sciwhiz12
Posted
9 hours ago, sciwhiz12 said:

Put your registerConfig call in your mod constructor.

Mod event order:

  • Mod construction (move yourregisterConfig here)
  • RegistryEvent.Register<T>
  • Config loading
  • Common setup (your registerConfig was in here)
  • Sided setup
  • ...

See ModLoader.loadMods, line 152 for source.

Alright, that works. I was registering it in a static FMLCommonSetupEvent method that was registered with @EventBusSubscriber and @SubscribeEvent.

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



×
×
  • Create New...

Important Information

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