-
Notifications
You must be signed in to change notification settings - Fork 4
AllVariantsLoadedEvent
Aram edited this page May 4, 2025
·
1 revision
The AllVariantsLoadedEvent is fired once all known variants for a particular entity have been registered. This allows mod developers to modify, add, or reject variants at the correct time in the loading lifecycle.
There are two phases to this event:
- Pre – allows cancellation or conditional filtering of variants.
- Post – triggered after all variants have been loaded.
Use this to dynamically adjust behavior or content related to entities with multiple variants (e.g., dragon types, mob skins, etc.).
- Can be used to cancel or prevent certain variants from being loaded.
- Only available if the event is cancellable (NeoForge) or returns false (Fabric).
- Used to react to the final set of loaded variants (e.g., logging, applying transformations).
- Remove certain variants based on config or biome rules.
- Inject additional custom variants dynamically.
- Log or validate the final list of variants after load.
NeoForge
You can listen to both Pre and Post events on the mod event bus:
@SubscribeEvent
public void onPreVariantsLoad(AllVariantsLoadedEvent.Pre event) {
if (event.getEntity().equals("example_entity")) {
event.setCanceled(true); // prevent all variants for this entity from loading
}
}
@SubscribeEvent
public void onPostVariantsLoad(AllVariantsLoadedEvent.Post event) {
System.out.println("All variants loaded for: " + event.getEntity());
}Register your event handler on the mod event bus:
ModLoadingContext.get().getModEventBus().register(new YourModEventHandler());Fabric
Use AllVariantsLoadedEvent.ALLOW_ALL_VARIANTS_TO_LOAD to allow or deny variant loading:
AllVariantsLoadedEvent.ALLOW_ALL_VARIANTS_TO_LOAD.register(entityName -> {
if (entityName.equals("example_entity")) {
return false; // deny loading all variants for this entity
}
return true;
});Use AllVariantsLoadedEvent.POST to react after all variants have been loaded:
AllVariantsLoadedEvent.POST.register(entityName -> {
System.out.println("All variants loaded for: " + entityName);
});- The
entityNamestring is used to identify which entity's variants are being handled. - You can use this event to interact with datapack-driven systems, especially if your entities or variants are defined in JSON.
Variant Loader
Data Pipeline
Network & Packets
Logging
Markdown
Utility Classes
- Conversion
- Math
- Minecraft
- Schedular