Class DataPackRegistryEvent.NewRegistry

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.registries.DataPackRegistryEvent
net.minecraftforge.registries.DataPackRegistryEvent.NewRegistry
All Implemented Interfaces:
IModBusEvent
Enclosing class:
DataPackRegistryEvent

public static final class DataPackRegistryEvent.NewRegistry extends DataPackRegistryEvent
Fired when datapack registries can be registered. Datapack registries are registries which can only load entries through JSON files from datapacks.

Data JSONs will be loaded from data/<datapack_namespace>/modid/registryname/, where modid is the namespace of the registry key.

This event is not cancellable, and does not have a result.

This event is fired on the mod-specific event bus, on both logical sides.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraftforge.registries.DataPackRegistryEvent

    DataPackRegistryEvent.DataPackRegistryData<T>, DataPackRegistryEvent.NewRegistry

    Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event

    net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    dataPackRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec)
    Registers the given registry key as an unsynced datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.
    <T> void
    dataPackRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec)
    Registers the registry key as a datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.
    (package private) void
     

    Methods inherited from class net.minecraftforge.eventbus.api.Event

    getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NewRegistry

      @Internal public NewRegistry()
  • Method Details

    • dataPackRegistry

      public <T> void dataPackRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec)
      Registers the given registry key as an unsynced datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name. The datapack registry is not required to be present on clients when connecting to servers with the mod/registry.

      Data JSONs will be loaded from data/<datapack_namespace>/modid/registryname/, where modid is the namespace of the registry key.

      Parameters:
      registryKey - the root registry key of the new datapack registry
      codec - the codec to be used for loading data from datapacks on servers
      See Also:
    • dataPackRegistry

      public <T> void dataPackRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, @Nullable @Nullable com.mojang.serialization.Codec<T> networkCodec)
      Registers the registry key as a datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.

      Data JSONs will be loaded from data/<datapack_namespace>/modid/registryname/, where modid is the namespace of the registry key.

      Parameters:
      registryKey - the root registry key of the new datapack registry
      codec - the codec to be used for loading data from datapacks on servers
      networkCodec - the codec to be used for syncing loaded data to clients. If networkCodec is null, data will not be synced, and clients are not required to have this datapack registry to join a server.

      If networkCodec is not null, clients must have this datapack registry/mod when joining a server that has this datapack registry/mod. The data will be synced using the network codec and accessible via ClientPacketListener.registryAccess().

      See Also:
    • process

      void process()