Interface DynamicRegistrySetupCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This event gets triggered when a new
DynamicRegistryManager
gets created, but before it gets filled.
Therefore, this is the ideal place to register callbacks to dynamic registries.
For example, the following code is used to register a callback that gets triggered for any registered Biome, both JSON and code defined.
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
registryManager.getOptional(Registry.BIOME_KEY).ifPresent(biomes -> {
RegistryEntryAddedCallback.event(biomes).register((rawId, id, object) -> {
// Do something
});
});
});
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 DynamicRegistryManager.getOptional(net.minecraft.registry.RegistryKey<? extends net.minecraft.registry.Registry<? extends E>>)
to prevent crashes.
- See Also:
-
Field Summary
Fields -
Method Summary
-
Field Details
-
EVENT
-
-
Method Details
-
onRegistrySetup
-