AllModsLoadedEvent - MeAlam1/BlueLib GitHub Wiki
The AllModsLoadedEvent
is triggered once all known mods and their metadata have been discovered and initialized by the loader. This is the final stage of mod discovery and a good point to inspect, validate, or interact with the full mod list.
Unlike entity events, this only has a single phase that occurs after all mods are loaded.
Use this event when you need complete awareness of the mod environment, such as dependency resolution, compatibility checking, or dynamic content adjustment based on which mods are present.
This event provides access to the full list of loaded mod metadata. You can:
- Read metadata like mod ID, version, or authors.
- Check for specific mod dependencies.
- Log or react based on which mods are loaded.
- Check if required companion mods are present before activating certain features.
- Warn users about known incompatibilities or missing dependencies.
- Register inter-mod integrations only when both mods are detected.
- Collect metadata for diagnostics or analytics.
Each loaded mod is represented as a ModMeta
record, which contains the following fields:
Field | Type | Description |
---|---|---|
modId |
String |
The internal mod ID used for identification (e.g., examplemod ). |
displayName |
String |
The user-facing name of the mod (e.g., Example Mod ). |
version |
String |
The version of the mod, typically in SemVer (e.g., 1.2.3 ). |
description |
String |
A short description of what the mod does. |
logoFile |
Optional<String> |
The path to the logo file used by the mod, if present. |
NeoForge
Use the mod event bus to listen for the AllModsLoadedEvent
:
@SubscribeEvent
public void onAllModsLoaded(AllModsLoadedEvent event) {
List<ModMeta> mods = event.getAllModsData();
for (ModMeta meta : mods) {
System.out.println("Loaded mod: " + meta.modId() + " - Version: " + meta.version());
}
// Check if a specific mod is present
ModMeta myMod = event.getModMetaById("examplemod");
if (myMod != null) {
System.out.println("examplemod is loaded!");
}
}
Register your event handler:
ModLoadingContext.get().getModEventBus().register(new YourModEventHandler());
Fabric
Use AllModsLoadedEvent.EVENT
to react once the mod list has been finalized:
AllModsLoadedEvent.EVENT.register(modData -> {
for (ModMeta meta : modData) {
System.out.println("Mod: " + meta.modId() + " (version: " + meta.version() + ")");
}
// Example: check for a specific mod
boolean hasExampleMod = modData.stream().anyMatch(meta -> meta.modId().equals("examplemod"));
if (hasExampleMod) {
System.out.println("examplemod is loaded!");
}
});
- The list of
ModMeta
objects gives you detailed info such as mod ID, version, authors, and more. - This event runs after all mods are loaded, so it's safe for final decisions or integrations.
- This is especially useful for cross-mod compatibility or optional feature toggling.