Class RegistryEvents
The events are to be used for very low-level purposes, and callbacks are only called on registry manipulations occurring after the event registration. This means that mod load order can affect what is picked up by these events.
For more high-level monitoring of registries, including methods to ease the inconvenience of mod load order, use RegistryMonitor.
Modified to work on Fabric
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfaceFunctional interface to be implemented on callbacks forgetEntryAddEvent(Registry). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.fabricmc.fabric.api.event.Event<RegistryEvents.DynamicRegistryLoadedCallback> This event gets triggered when a newRegistryAccessgets created, after it has been filled with the registry entries specified by data packs.static final net.fabricmc.fabric.api.event.Event<RegistryEvents.DynamicRegistrySetupCallback> This event gets triggered when a newRegistryAccessgets created, but before it gets filled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> net.fabricmc.fabric.api.event.Event<RegistryEvents.EntryAdded<V>> getEntryAddEvent(net.minecraft.core.Registry<V> registry) Gets the entry added event for a specific Minecraft registry.
-
Field Details
-
DYNAMIC_REGISTRY_SETUP
public static final net.fabricmc.fabric.api.event.Event<RegistryEvents.DynamicRegistrySetupCallback> DYNAMIC_REGISTRY_SETUPThis event gets triggered when a newRegistryAccessgets created, but before it gets filled.This event can be used to register callbacks to dynamic registries, or to pre-fill some values.
Important Note: The passed dynamic registry manager might not contain the registry, as this event is invoked for each layer of the combined registry manager, and each layer holds different registries. Use
RegistryAccess.registry(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<? extends E>>)to prevent crashes. -
DYNAMIC_REGISTRY_LOADED
public static final net.fabricmc.fabric.api.event.Event<RegistryEvents.DynamicRegistryLoadedCallback> DYNAMIC_REGISTRY_LOADEDThis event gets triggered when a newRegistryAccessgets created, after it has been filled with the registry entries specified by data packs.This event can be used to register callbacks to dynamic registries, or to inspect values.
Important Note: The passed dynamic registry manager might not contain the registry, as this event is invoked for each layer of the combined registry manager, and each layer holds different registries. Use
RegistryAccess.registry(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<? extends E>>)to prevent crashes.
-
-
Constructor Details
-
RegistryEvents
public RegistryEvents()
-
-
Method Details
-
getEntryAddEvent
public static <V> net.fabricmc.fabric.api.event.Event<RegistryEvents.EntryAdded<V>> getEntryAddEvent(net.minecraft.core.Registry<V> registry) Gets the entry added event for a specific Minecraft registry.The event is invoked upon the addition or assignment of an entry in the specified registry.
- Type Parameters:
V- the entry type of theRegistryto listen for- Parameters:
registry- theRegistryfor this event to listen for. Must be an instance ofMappedRegistry.- Returns:
- the entry added event for the specified registry, which can have callbacks registered to it
- Throws:
ClassCastException- if the registry is not aMappedRegistry
-