Class DataMapsUpdatedEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.registries.datamaps.DataMapsUpdatedEvent
public class DataMapsUpdatedEvent
extends net.neoforged.bus.api.Event
Event fired on the
game event bus
when the data maps of
a registry have either been synced to the client or reloaded on the server.
This event can be used to build caches (like weighed lists) or for post-processing the data map values.
Remember however that the data map values should not end up referencing their owner, as they're not copied when attached to tags.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataMapsUpdatedEvent.UpdateCause
private final net.minecraft.core.Registry
<?> private final net.minecraft.core.RegistryAccess
-
Constructor Summary
ConstructorsConstructorDescriptionDataMapsUpdatedEvent
(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Registry<?> registry, DataMapsUpdatedEvent.UpdateCause cause) -
Method Summary
Modifier and TypeMethodDescriptiongetCause()
Returns the reason for the update.net.minecraft.core.RegistryAccess
Returns a registry access.net.minecraft.core.Registry
<?> Returns the registry that had its data maps updated.net.minecraft.resources.ResourceKey
<? extends net.minecraft.core.Registry<?>> Returns the key of the registry that had its data maps updated.<T> void
ifRegistry
(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> type, Consumer<net.minecraft.core.Registry<T>> consumer) Runs the givenconsumer
if the registry is of the giventype
.
-
Field Details
-
registryAccess
private final net.minecraft.core.RegistryAccess registryAccess -
registry
private final net.minecraft.core.Registry<?> registry -
cause
-
-
Constructor Details
-
DataMapsUpdatedEvent
@Internal public DataMapsUpdatedEvent(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Registry<?> registry, DataMapsUpdatedEvent.UpdateCause cause)
-
-
Method Details
-
getRegistries
public net.minecraft.core.RegistryAccess getRegistries()Returns a registry access.- Returns:
- a registry access
-
getRegistry
public net.minecraft.core.Registry<?> getRegistry()Returns the registry that had its data maps updated.- Returns:
- the registry that had its data maps updated
-
getRegistryKey
public net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<?>> getRegistryKey()Returns the key of the registry that had its data maps updated.- Returns:
- the key of the registry that had its data maps updated
-
ifRegistry
public <T> void ifRegistry(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> type, Consumer<net.minecraft.core.Registry<T>> consumer) Runs the givenconsumer
if the registry is of the giventype
.- Type Parameters:
T
- the registry type- Parameters:
type
- the registry keyconsumer
- the consumer
-
getCause
Returns the reason for the update.- Returns:
- the reason for the update
-