Class NewDatapackRegistryEvent
- All Implemented Interfaces:
IModBusEvent
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.
This event is fired on the mod-specific event bus, on both physical sides.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<NewDatapackRegistryEvent.RegistryData<?>> private final List<NewDatapackRegistryEvent.RegistryData<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidprocess()<T> voidreloadableRegistry(Consumer<DatapackRegistryBuilder<T>> builderConsumer) Registers a reloadable datapack registry as configured by the builder given to the provided consumer, which will cause data to be loaded from a datapack folder based on the registry's name.<T> voidreloadableRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec) Registers the given registry key as a reloadable datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.<T> voidworldRegistry(Consumer<DatapackRegistryBuilder<T>> builderConsumer) Registers a world datapack registry as configured by the builder given to the provided consumer, which will cause data to be loaded from a datapack folder based on the registry's name.<T> voidworldRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec) Registers the given registry key as an unsynced world datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.<T> voidworldRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec) Registers the registry key as a world datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.
-
Field Details
-
worldRegistries
-
reloadableRegistries
-
-
Constructor Details
-
NewDatapackRegistryEvent
NewDatapackRegistryEvent()
-
-
Method Details
-
worldRegistry
public <T> void worldRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec) Registers the given registry key as an unsynced world 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/, wheremodidis the namespace of the registry key.World registries are only loaded once during server startup.
- Parameters:
registryKey- The root registry key of the new datapack registrycodec- The codec to be used for loading data from datapacks on servers- See Also:
-
worldRegistry
public <T> void worldRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec) Registers the registry key as a world 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/, wheremodidis the namespace of the registry key.World registries are only loaded once during server startup.
- Parameters:
registryKey- The root registry key of the new datapack registrycodec- The codec to be used for loading data from datapacks on serversnetworkCodec-The codec to be used for syncing loaded data to clients. If
networkCodecis 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:
-
worldRegistry
Registers a world datapack registry as configured by the builder given to the provided consumer, which will cause data to be loaded from a datapack folder based on the registry's name. At least a registry key and a loading codec are required to create the registry.
Data JSONs will be loaded from
data/<datapack_namespace>/modid/registryname/, wheremodidis the namespace of the registry key.World registries are only loaded once during server startup.
- Parameters:
builderConsumer- A consumer that configures the providedDatapackRegistryBuilder- See Also:
-
reloadableRegistry
public <T> void reloadableRegistry(ResourceKey<Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec) Registers the given registry key as a reloadable 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/, wheremodidis the namespace of the registry key.Reloadable registries are loaded on server startup and by the
/reloadcommand.- Parameters:
registryKey- The root registry key of the new datapack registrycodec- The codec to be used for loading data from datapacks on servers- See Also:
-
reloadableRegistry
Registers a reloadable datapack registry as configured by the builder given to the provided consumer, which will cause data to be loaded from a datapack folder based on the registry's name. At least a registry key and a loading codec are required to create the registry.
Data JSONs will be loaded from
data/<datapack_namespace>/modid/registryname/, wheremodidis the namespace of the registry key.Reloadable registries are loaded on server startup and by the
/reloadcommand.- Parameters:
builderConsumer- A consumer that configures the providedDatapackRegistryBuilder- See Also:
-
process
void process()
-