Jump to content

Recommended Posts

Posted

I've just updated my Ore Generation mod to 1.19 using BiomeModifiers and RegistryObject<ConfiguredFeature>, etc., and the ores are generated as expected.

However, it seems that if I try and use ForgeConfig to configure the parameters of the OreConfiguration being passed into the ConfiguredFeature for the RegistryObject, I get an error saying how the Config cannot be used before it is instantiated.
Is there a different lifecycle step that I should be initializing my config or my Feature registry? Is it still possible to have ForgeConfig that affects OreGeneration?

Thanks!

Posted (edited)

I'm using a Common config. Would a Server config avoid throwing this error?

Edit: Error still seems to be thrown regardless of type of config, whether it be Server, Client, or Common.

Edited by Zetal911
Posted
40 minutes ago, Zetal911 said:

I'm using a Common config. Would a Server config avoid throwing this error?

In this case you should always use a server config, since the config will be synced to the client.
If you use a common config it could be that server and client values do not match.

Another aspect of the server config it is not loaded until server start.

Please show your code and post the debug.log.

Posted (edited)

https://pastebin.com/LnRcubaZ

Log ^

Constructor

    public HardModeOresMod() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
    	ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, HardModeOresConfig.COMMON_SPEC); 
        HardModeOresFeatureRegistry.register(modEventBus);
        HardModeOresRegistry.BLOCK_REGISTRY.register(modEventBus);
	HardModeOresRegistry.ITEM_REGISTRY.register(modEventBus);
    }

 

Example where I'm trying to use the config values

    public static final RegistryObject<ConfiguredFeature<?, ?>> ORE_IRON_CFG = CONFIGURED_FEATURES.register("ore_rich_iron", () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(ORE_IRON_TARGET_LIST.get(), HardModeOresConfig.COMMON.IronMaxVeinSize.get())));

 

Config Constructor

	

	public static final Common COMMON;
	public static final ForgeConfigSpec COMMON_SPEC;

	static //constructor
	{
		Pair<Common, ForgeConfigSpec> commonSpecPair = new ForgeConfigSpec.Builder().configure(Common::new);
		COMMON = commonSpecPair.getLeft();
		COMMON_SPEC = commonSpecPair.getRight();
	}

 

Common Constructor

public Common(ForgeConfigSpec.Builder builder)
{
  builder.push("Ores");
  this.IronMaxVeinSize = builder.worldRestart().define("Rich Iron Max Vein Size", defaultIronMaxVeinSize);
  this.GoldMaxVeinSize = builder.worldRestart().define("Rich Gold Max Vein Size", defaultGoldMaxVeinSize);
  this.DiamondMaxVeinSize = builder.worldRestart().define("Rich Diamond Max Vein Size", defaultDiamondMaxVeinSize);
  builder.pop();
}

 

 

Should be everything relevant. Note that despite the Config being named 'Common', it is using the Server config type, and is still failing in the same way.

It seems that Configs are not loaded until server/world start, but OreGeneration Registration is registered when opening the world creation screen. Does this mean that it is now impossible to use ForgeConfig to configure OreGeneration?

Edited by Zetal911
Posted

The normal way for a user to override world gen configuration is to use a datapack, e.g. they can provide their own definition of your configured feature.

 

Since you are registering the configured features at mod loading time, a server config is wrong here, server configs belong to the game save which doesn't exist at that point.

It is also unnecessary, because world gen is also part of the game save. The values in your configuration will only be checked during the create new world screen, after that it will use the saved values.

 

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
2 minutes ago, diesieben07 said:

You cannot do this. Configs are loaded after registration. Registration values cannot depend on config values.

The docs says you should load manually if you want to do this:

https://forge.gemwire.uk/wiki/Stages_of_Modloading

I don't know how to do this, Maybe ConfigTracker.INSTANCE.loadConfigs()?

Or maybe the docs are out-of-date?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

Okay. I was trying to update my 1.16 mod, which supported this, to 1.19. It's a shame to lose that kind of configuration control for users, but at least it's good to know there's nothing to be done about it.

Thanks, all.

Posted

Config loading hasn't, true, but the removal of BiomeLoadingEvent (in 1.18.2 I think?) means that configs cannot be used in that later step, which was after they'd been loaded.

It doesn't really matter either way though now that I've figured out how to use Feature datapacks, it's just for the sake of discussion I guess.

Posted (edited)

BiomeLoadingEvent is replaced with BiomeModifiers.

https://forge.gemwire.uk/wiki/Biome_Modifiers

 

If you really wanted to implement it the way you used to do it,

you could make your own OreConfiguration/Feature implementation that gets its value from your config instead of being passed a number.

 

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
6 minutes ago, warjort said:

BiomeLoadingEvent is replaced with BiomeModifiers.

https://forge.gemwire.uk/wiki/Biome_Modifiers

 

If you really wanted to implement it the way you used to do it,

you could make your own OreConfiguration/Feature implementation that gets its value from your config instead of being passed a number.

 

This is exactly what I attempted to do, but as described earlier in the thread, it is now impossible because the new way of doing OreConfig/Feature is using a Registry, and Registration is called before Config is loaded.

Posted

No you wouldn't reference the config at registration time, you would do it at runtime inside the Feature.place()

The only reason I can see to do such a thing is if you want to change the values after the world is created.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.