Config Loading Events on 1.20.2 and Up - Fuzss/forgeconfigapiport GitHub Wiki

Available config event types

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 on ModConfig.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 the FileWatcher 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.

Listening to NeoForge api events on Fabric

fuzs.forgeconfigapiport.fabric.api.neoforge.v4.NeoForgeModConfigEvents.loading(<modId>).register((net.neoforged.fml.config.ModConfig config) -> {
    <...>
});

Listening to Forge api events on Fabric

fuzs.forgeconfigapiport.fabric.api.forge.v4.ForgeModConfigEvents.loading(<modId>).register((net.minecraftforge.fml.config.ModConfig config) -> {
    <...>
});

Listening to Forge api events on NeoForge

net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext.get().getModEventBus().addListener((final net.neoforged.fml.event.config.ModConfigEvent.Loading evt) -> {
    <...>
});

Listening to NeoForge api events on Forge

net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.get().getModEventBus().addListener((final net.minecraftforge.fml.event.config.ModConfigEvent.Loading evt) -> {
    <...>
});
⚠️ **GitHub.com Fallback** ⚠️