Class DatapackRegistryBuilder<T>
java.lang.Object
net.neoforged.neoforge.registries.DatapackRegistryBuilder<T>
Builder for world and reloadable datapack registries.
At least a registry key and a loading codec are required to create a dapatack registry.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Consumer<RegistryBuilder<T>> private @Nullable ResourceKey<Registry<T>> private final booleanprivate RegistryValidator<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) NewDatapackRegistryEvent.RegistryData<T> build()Specify the codec to be used for loading data from datapacks on servers.configurator(Consumer<RegistryBuilder<T>> configurator) Specify a consumer that configures the providedRegistryBuilder.key(ResourceKey<Registry<T>> key) Specify the root registry key of the new datapack registry.networkCodec(com.mojang.serialization.Codec<T> networkCodec) Specify the codec to be used for syncing loaded data to clients.validator(RegistryValidator<T> validator) Specify a validator to check the datapack registry after it was loaded.
-
Field Details
-
reloadable
private final boolean reloadable -
key
-
codec
-
networkCodec
-
validator
-
configurator
-
-
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
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
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
Specify a validator to check the datapack registry after it was loaded.- Parameters:
validator- The validator to use- Returns:
- this builder
-
configurator
Specify a consumer that configures the providedRegistryBuilder.- Parameters:
configurator- The registry configurator- Returns:
- this builder
-
build
NewDatapackRegistryEvent.RegistryData<T> build()
-