From 7a24414dad609180c3f6cabab101abdd6490c8a3 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Fri, 23 Feb 2024 01:13:58 +0100 Subject: [PATCH] fix datapack registry creation --- docs/concepts/registries.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/concepts/registries.md b/docs/concepts/registries.md index 27c5959f5..4c9939ac3 100644 --- a/docs/concepts/registries.md +++ b/docs/concepts/registries.md @@ -198,12 +198,14 @@ Datapack registries can be obtained from a `RegistryAccess`. This `RegistryAcces ### Custom Datapack Registries -Custom datapack registries are created through `RegistryBuilder` like all other registries, but are registered to `DataPackRegistryEvent.NewRegistry` instead of `NewRegistryEvent`. Reiterating the spells example from before, registering our spell registry as a datapack registry looks something like this: +Custom datapack registries do not require a `Registry` to be constructed. Instead, they just need a registry key and at least one [`Codec`][codec] to (de-)serialize its contents. Reiterating on the spells example from before, registering our spell registry as a datapack registry looks something like this: ```java +public static final ResourceKey> SPELL_REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation("yourmodid", "spells")); + @SubscribeEvent -static void registerDatapackRegistries(DataPackRegistryEvent.NewRegistry event) { - event.register( +public static void registerDatapackRegistries(DataPackRegistryEvent.NewRegistry event) { + event.dataPackRegistry( // The registry key. SPELL_REGISTRY_KEY, // The codec of the registry contents.