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.

  • Field Details

    • registryAccess

      private final net.minecraft.core.RegistryAccess registryAccess
    • registry

      private final net.minecraft.core.Registry<?> registry
    • cause

      private final DataMapsUpdatedEvent.UpdateCause 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 given consumer if the registry is of the given type.
      Type Parameters:
      T - the registry type
      Parameters:
      type - the registry key
      consumer - the consumer
    • getCause

      Returns the reason for the update.
      Returns:
      the reason for the update