React to Configuration Changes in Your Mod
Using Callbacks to Stay in Sync
VanillaConfig provides callback hooks so your mod can respond when settings change, either from the config file or the in-game screen.
Registering and Using Callbacks
1. Load callbacks: Register these to run after the config is loaded from disk. Use them to initialize cached values or apply settings at startup.
2. Save callbacks: Register before-save or after-save callbacks to validate changes or trigger side effects when the player saves.
3. Change callbacks: Attach these to specific config entries to react immediately when that option is modified, even before saving.
For example, register a change callback on a difficulty setting to update game rules in real-time, or on a performance option to refresh rendering settings. This keeps your mod's behavior synchronized with the player's configuration without requiring a restart. Callbacks are essential for responsive, dynamic configuration handling.