Config Loading Events on 1.20.2 and Up - Fuzss/forgeconfigapiport GitHub Wiki
The NeoForge / Forge config system implements a few events related to different config loading actions which are useful for e.g. manually updating and invalidating config-backed mod data.
-
Loading
: Fired during mod (client & common configs) and server (server configs) loading, depending onModConfig.Type
of config file. Any config objects associated with this will be valid and can be queried directly. -
Reloading
: Fired when the configuration is changed. This can be caused by theFileWatcher
detecting a change to the config file, or by a server synchronizing a server config to a connecting client. -
Unloading
: Fired when a config is unloaded. This only happens when the server closes. The config file will be saved after this event has fired.
fuzs.forgeconfigapiport.fabric.api.neoforge.v4.NeoForgeModConfigEvents.loading(<modId>).register((net.neoforged.fml.config.ModConfig config) -> {
<...>
});
fuzs.forgeconfigapiport.fabric.api.forge.v4.ForgeModConfigEvents.loading(<modId>).register((net.minecraftforge.fml.config.ModConfig config) -> {
<...>
});
net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext.get().getModEventBus().addListener((final net.neoforged.fml.event.config.ModConfigEvent.Loading evt) -> {
<...>
});
net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.get().getModEventBus().addListener((final net.minecraftforge.fml.event.config.ModConfigEvent.Loading evt) -> {
<...>
});