Config Loading Events (for Minecraft 1.21.5 and up) - Fuzss/forge-config-api-port GitHub Wiki

Available config event types

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 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.v5.ModConfigEvents.loading(<modId>).register((net.neoforged.fml.config.ModConfig config) -> {
    <...>
});

Listening to Minecraft Forge api events on Fabric

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

Listening to Minecraft 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 Minecraft Forge

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