Wiki 9Minecraft Wiki 9Minecraft

Config Loading Events (For Minecraft 1.21.5 And Up)

Java EditionModGuides 4FAQ 20Related mods 48
DownloadForge Config API Port Mod

Get the files on 9Minecraft

Contents (5)
  1. Available config event types
  2. Listening to NeoForge api events on Fabric
  3. Listening to Minecraft Forge api events on Fabric
  4. Listening to Minecraft Forge api events on NeoForge
  5. Listening to NeoForge api events on Minecraft Forge

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) -> {
    <...>
});