Config Loading Events (for Minecraft 1.21.5 and up) - Fuzss/forge-config-api-port GitHub Wiki
The NeoForge / Minecraft 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.Typeof 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 theFileWatcherdetecting 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.v5.ModConfigEvents.loading(<modId>).register((net.neoforged.fml.config.ModConfig config) -> {
<...>
});fuzs.forgeconfigapiport.fabric.api.v5.ModConfigEvents.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) -> {
<...>
});