Class DatapackRegistryBuilder<T>

java.lang.Object
net.neoforged.neoforge.registries.DatapackRegistryBuilder<T>

public final class DatapackRegistryBuilder<T> extends Object

Builder for world and reloadable datapack registries.

At least a registry key and a loading codec are required to create a dapatack registry.

  • Field Details

  • Constructor Details

    • DatapackRegistryBuilder

      DatapackRegistryBuilder(boolean reloadable)
  • Method Details

    • key

      Specify the root registry key of the new datapack registry. This property is required in order to create the registry.
      Parameters:
      key - The key of the registry
      Returns:
      this builder
    • codec

      public DatapackRegistryBuilder<T> codec(com.mojang.serialization.Codec<T> codec)
      Specify the codec to be used for loading data from datapacks on servers. This property is required in order to create the registry.
      Parameters:
      codec - The codec to use
      Returns:
      this builder
    • networkCodec

      public DatapackRegistryBuilder<T> networkCodec(com.mojang.serialization.Codec<T> networkCodec)

      Specify the codec to be used for syncing loaded data to clients.

      If a network codec is specified, 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

      invalid reference
      ClientPacketListener#registryAccess()
      .
      Parameters:
      networkCodec - The network codec to use
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if this builder is for a reloadable datapack registry, which does not support syncing
    • validator

      public DatapackRegistryBuilder<T> validator(RegistryValidator<T> validator)
      Specify a validator to check the datapack registry after it was loaded.
      Parameters:
      validator - The validator to use
      Returns:
      this builder
    • configurator

      public DatapackRegistryBuilder<T> configurator(Consumer<RegistryBuilder<T>> configurator)
      Specify a consumer that configures the provided RegistryBuilder.
      Parameters:
      configurator - The registry configurator
      Returns:
      this builder
    • build