Register config properties in the spec of their location - #252
Merged
Merged
Conversation
Properties were always defined on the COMMON spec builder, so CLIENT and SERVER properties ended up in the common (local) config file and their own specs stayed empty. Each property now goes into the builder of its configLocation, and loading or reloading a config only syncs the properties that belong to it, since values of a config that is not loaded yet cannot be read. This is a breaking change: values that were customized in the common config file for CLIENT or SERVER properties are no longer read. Also add a TODO to rename COMMON and SERVER to match NeoForge's LOCAL and SYNCED config types in the next major version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSz5r6eowhjNuANBjZE2v6
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
ConfigHandlerNeoForge,ConfigHandlerForgeandConfigHandlerFabricHandlercreate a spec builder perModConfigLocation, but then pass the COMMON builder toonConfigPropertyInitfor every property. As a result:@ConfigurablePropertyCommonends up in the common config file (-local.tomlon NeoForge 26), whatever itsconfigLocation.This goes back to before the multiloader port (
configProperty.onConfigInit(configBuilder)in the oldConfigHandler).Fix
initializepasses the property's own builder (configBuilderProperty) toonConfigPropertyInit.syncProcessedConfigsonly writes back properties whose location matches the type of the config being loaded or reloaded. Without this, loading the common config would read values from a CLIENT or SERVER spec that isn't loaded yet, which throws. On Fabric this changessyncProcessedConfigs(boolean)tosyncProcessedConfigs(ModConfig, boolean), matching the other loaders.ModConfigLocationto renameCOMMONandSERVERin the next major, to match NeoForge'sLOCALandSYNCED(whatmodConfigLocationToTypealready maps them to).Breaking change
On
master-26only, as discussed. Values players customized in the common file for properties marked CLIENT or SERVER are no longer read. Those properties start from their defaults in their new file (client config, or the synced/server config). Server admins and pack makers who changed such options need to set them again.Validation
./gradlew buildpasses../gradlew runGameTestServer: "All 4 required tests passed" on NeoForge, Forge and Fabric, before and after the change.master-26, then again with this change. Cyclops Core's ownGeneralConfighas two CLIENT properties (devWorldButton,devDisableMusic):cyclopscore-common.toml(Fabric, Forge) andcyclopscore-local.toml(NeoForge).cyclopscore-client.toml. Fabric writes it even on a dedicated server; NeoForge and Forge don't create a client config on a dedicated server. No Cyclops Core config file is written on the server for NeoForge and Forge, since Cyclops Core has no COMMON or SERVER properties of its own.initializeneeds a live mod container and registers configs globally, so testing it needs a refactor I'd rather not mix into this fix.Not included
minimalValue/maximalValuefrom the annotation aren't enforced: properties usedefinerather thandefineInRange. That's a separate change, which could also land onmaster-26if wanted.🤖 Generated with Claude Code
https://claude.ai/code/session_01RSz5r6eowhjNuANBjZE2v6
Generated by Claude Code