diff --git a/patches/api/0501-RegistryValue-API.patch b/patches/api/0501-RegistryValue-API.patch new file mode 100644 index 0000000000..c240905a2a --- /dev/null +++ b/patches/api/0501-RegistryValue-API.patch @@ -0,0 +1,222 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sun, 24 Nov 2024 02:38:39 -0800 +Subject: [PATCH] RegistryValue API + + +diff --git a/src/main/java/io/papermc/paper/registry/DirectRegistryValue.java b/src/main/java/io/papermc/paper/registry/DirectRegistryValue.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0ec719e90043167af5156f4c8ec2e7d823a87939 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/DirectRegistryValue.java +@@ -0,0 +1,10 @@ ++package io.papermc.paper.registry; ++ ++record DirectRegistryValue(T value) implements RegistryValue.Direct { ++ ++ DirectRegistryValue { ++ if (!RegistryUtilProvider.INSTANCE.orElseThrow().isValidForDirectHolder(value)) { ++ throw new IllegalArgumentException("Value is not valid for direct holder"); ++ } ++ } ++} +diff --git a/src/main/java/io/papermc/paper/registry/RegistryCreationLookup.java b/src/main/java/io/papermc/paper/registry/RegistryCreationLookup.java +new file mode 100644 +index 0000000000000000000000000000000000000000..332bc17c016d248f3ae3134e59a3c2b5338c6fb0 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/RegistryCreationLookup.java +@@ -0,0 +1,38 @@ ++package io.papermc.paper.registry; ++ ++import io.papermc.paper.registry.tag.Tag; ++import io.papermc.paper.registry.tag.TagKey; ++import org.bukkit.Keyed; ++import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; ++ ++/** ++ * A lookup for {@link io.papermc.paper.registry.event.RegistryEvent}s to get ++ * or create tags and registry values. ++ */ ++@ApiStatus.Experimental ++@NullMarked ++@ApiStatus.NonExtendable ++public interface RegistryCreationLookup { ++ ++ /** ++ * Gets or creates a tag for the given tag key. This tag ++ * is then required to be filled either from the built-in or ++ * custom datapack. ++ * ++ * @param tagKey the tag key ++ * @param the tag value type ++ * @return the tag ++ */ ++ Tag getOrCreateTag(TagKey tagKey); ++ ++ /** ++ * Gets or creates a registry value for the given typed key. If ++ * it's created, it's required to be filled during some later event. ++ * ++ * @param typedKey the typed key ++ * @param the value type ++ * @return the registry value ++ */ ++ RegistryValue.Reference getOrCreateValue(TypedKey typedKey); ++} +diff --git a/src/main/java/io/papermc/paper/registry/RegistryUtilProvider.java b/src/main/java/io/papermc/paper/registry/RegistryUtilProvider.java +new file mode 100644 +index 0000000000000000000000000000000000000000..5adf17f309b4a58a9ae77284ef3f3e3e190b7dc3 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/RegistryUtilProvider.java +@@ -0,0 +1,14 @@ ++package io.papermc.paper.registry; ++ ++import java.util.Optional; ++import java.util.ServiceLoader; ++import org.jetbrains.annotations.ApiStatus; ++ ++@ApiStatus.Internal ++interface RegistryUtilProvider { ++ ++ Optional INSTANCE = ServiceLoader.load(RegistryUtilProvider.class).findFirst(); ++ ++ ++ boolean isValidForDirectHolder(V value); ++} +diff --git a/src/main/java/io/papermc/paper/registry/RegistryValue.java b/src/main/java/io/papermc/paper/registry/RegistryValue.java +new file mode 100644 +index 0000000000000000000000000000000000000000..6b7fb0a9b051589ee35859ca323faf3d765e32fb +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/RegistryValue.java +@@ -0,0 +1,49 @@ ++package io.papermc.paper.registry; ++ ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.Contract; ++import org.jspecify.annotations.NullMarked; ++ ++/** ++ * A value associated with a registry. This wrapper ++ * exists to represents values that might not be inside ++ * a registry yet, but are needed to construct some other ++ * objects in other registries. ++ * ++ * @param the value type ++ */ ++@ApiStatus.Experimental ++@NullMarked ++@ApiStatus.NonExtendable ++public sealed interface RegistryValue { ++ ++ // TODO uncomment when direct holders are supported ++ // /** ++ // * Create a direct registry value. A direct registry value ++ // * is a value that is anonymous (not registered in a registry). ++ // * ++ // * @param value the value ++ // * @param the value type ++ // * @return the direct registry value ++ // */ ++ // @Contract(value = "_ -> new", pure = true) ++ // static RegistryValue.Direct direct(final T value) { ++ // return new DirectRegistryValue<>(value); ++ // } ++ ++ @ApiStatus.Experimental ++ @ApiStatus.NonExtendable ++ non-sealed interface Reference extends RegistryValue { ++ ++ @Contract(pure = true) ++ TypedKey key(); ++ } ++ ++ @ApiStatus.Experimental ++ @ApiStatus.NonExtendable ++ sealed interface Direct extends RegistryValue permits DirectRegistryValue { ++ ++ @Contract(pure = true) ++ T value(); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEvent.java b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEvent.java +index 56468b311e40a6d1aa03c6d31328952b92e95027..0d18e09bd9d06dc83b53fa78e2c45710114dfdf8 100644 +--- a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEvent.java ++++ b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEvent.java +@@ -1,10 +1,8 @@ + package io.papermc.paper.registry.event; + + import io.papermc.paper.registry.RegistryBuilder; ++import io.papermc.paper.registry.RegistryCreationLookup; + import io.papermc.paper.registry.TypedKey; +-import io.papermc.paper.registry.tag.Tag; +-import io.papermc.paper.registry.tag.TagKey; +-import org.bukkit.Keyed; + import org.jetbrains.annotations.ApiStatus; + import org.jspecify.annotations.NullMarked; + +@@ -19,7 +17,7 @@ import org.jspecify.annotations.NullMarked; + @ApiStatus.Experimental + @NullMarked + @ApiStatus.NonExtendable +-public interface RegistryEntryAddEvent> extends RegistryEvent { ++public interface RegistryEntryAddEvent> extends RegistryEvent, RegistryCreationLookup { + + /** + * Gets the builder for the entry being added to the registry. +@@ -34,15 +32,4 @@ public interface RegistryEntryAddEvent> extends + * @return the key + */ + TypedKey key(); +- +- /** +- * Gets or creates a tag for the given tag key. This tag +- * is then required to be filled either from the built-in or +- * custom datapack. +- * +- * @param tagKey the tag key +- * @return the tag +- * @param the tag value type +- */ +- Tag getOrCreateTag(TagKey tagKey); + } +diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEvent.java b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEvent.java +index 59e8ca6c5b7fa0424ad9b2c74545ec53444b5fcb..e09eb10aafc312fedf7fdec39860b31468037b00 100644 +--- a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEvent.java ++++ b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEvent.java +@@ -1,9 +1,7 @@ + package io.papermc.paper.registry.event; + + import io.papermc.paper.registry.RegistryBuilder; +-import io.papermc.paper.registry.tag.Tag; +-import io.papermc.paper.registry.tag.TagKey; +-import org.bukkit.Keyed; ++import io.papermc.paper.registry.RegistryCreationLookup; + import org.jetbrains.annotations.ApiStatus; + import org.jspecify.annotations.NullMarked; + +@@ -18,7 +16,7 @@ import org.jspecify.annotations.NullMarked; + @ApiStatus.Experimental + @NullMarked + @ApiStatus.NonExtendable +-public interface RegistryFreezeEvent> extends RegistryEvent { ++public interface RegistryFreezeEvent> extends RegistryEvent, RegistryCreationLookup { + + /** + * Get the writable registry. +@@ -26,15 +24,4 @@ public interface RegistryFreezeEvent> extends Re + * @return a writable registry + */ + WritableRegistry registry(); +- +- /** +- * Gets or creates a tag for the given tag key. This tag +- * is then required to be filled either from the built-in or +- * custom datapack. +- * +- * @param tagKey the tag key +- * @return the tag +- * @param the tag value type +- */ +- Tag getOrCreateTag(TagKey tagKey); + } diff --git a/patches/server/1073-RegistryValue-API.patch b/patches/server/1073-RegistryValue-API.patch new file mode 100644 index 0000000000..c18cd54fc3 --- /dev/null +++ b/patches/server/1073-RegistryValue-API.patch @@ -0,0 +1,321 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sun, 24 Nov 2024 02:38:50 -0800 +Subject: [PATCH] RegistryValue API + + +diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java +index 7e5d1d4f563dfd4beef9cd73b3670714c96bacaf..d306b81ff6dcb614202d4d4ee294915f48868264 100644 +--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java ++++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java +@@ -7,6 +7,7 @@ import io.papermc.paper.datacomponent.PaperComponentType; + import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry; + import io.papermc.paper.registry.data.PaperGameEventRegistryEntry; + import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry; ++import io.papermc.paper.registry.entry.CraftRegistryEntry; + import io.papermc.paper.registry.entry.RegistryEntry; + import io.papermc.paper.registry.tag.TagKey; + import java.util.Collections; +@@ -14,6 +15,7 @@ import java.util.IdentityHashMap; + import java.util.List; + import java.util.Map; + import java.util.Objects; ++import net.minecraft.core.Holder; + import net.minecraft.core.Registry; + import net.minecraft.core.registries.Registries; + import net.minecraft.resources.ResourceKey; +@@ -54,6 +56,7 @@ import org.bukkit.craftbukkit.legacy.FieldRename; + import org.bukkit.craftbukkit.map.CraftMapCursor; + import org.bukkit.craftbukkit.potion.CraftPotionEffectType; + import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.craftbukkit.util.Handleable; + import org.bukkit.damage.DamageType; + import org.bukkit.enchantments.Enchantment; + import org.bukkit.entity.Cat; +@@ -169,6 +172,30 @@ public final class PaperRegistries { + return net.minecraft.tags.TagKey.create((ResourceKey>) registryToNms(tagKey.registryKey()), PaperAdventure.asVanilla(tagKey.key())); + } + ++ @SuppressWarnings("unchecked") ++ public static Holder toNms(final RegistryValue registryValue) { ++ if (registryValue instanceof ReferenceRegistryValue) { ++ return ((ReferenceRegistryValue) registryValue).holder(); ++ } else { ++ final A apiValue = ((RegistryValue.Direct) registryValue).value(); ++ // only Handleable is supported inside RegistryValue.Direct ++ return ((Handleable) apiValue).getHandleHolder(); ++ } ++ } ++ ++ public static RegistryValue fromNms(final RegistryKey registryKey, final Holder holder) { // TODO remove Keyed ++ if (holder instanceof final Holder.Reference reference) { ++ return new ReferenceRegistryValue<>(reference); ++ } else { ++ final @Nullable RegistryEntry entry = getEntry(registryKey); ++ if (!(entry instanceof final CraftRegistryEntry craftRegistryEntry)) { ++ throw new UnsupportedOperationException("Cannot create a direct value for " + registryKey); ++ } ++ return new DirectRegistryValue<>(craftRegistryEntry.convertDirectHolder(holder)); ++ } ++ ++ } ++ + private PaperRegistries() { + } + } +diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryUtilProvider.java b/src/main/java/io/papermc/paper/registry/PaperRegistryUtilProvider.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3ee9e5bf92baa643252bdf3ea6a52d058e7e2acc +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/PaperRegistryUtilProvider.java +@@ -0,0 +1,19 @@ ++package io.papermc.paper.registry; ++ ++import net.minecraft.core.Holder; ++import org.bukkit.craftbukkit.util.Handleable; ++import org.jspecify.annotations.NullMarked; ++ ++@NullMarked ++public class PaperRegistryUtilProvider implements RegistryUtilProvider { ++ ++ @Override ++ public boolean isValidForDirectHolder(final V value) { ++ if (!(value instanceof final Handleable handleable)) { ++ return false; ++ } ++ final Holder holder = handleable.getHandleHolder(); ++ if (holder == null) return false; ++ return holder.kind() == Holder.Kind.DIRECT; ++ } ++} +diff --git a/src/main/java/io/papermc/paper/registry/ReferenceRegistryValue.java b/src/main/java/io/papermc/paper/registry/ReferenceRegistryValue.java +new file mode 100644 +index 0000000000000000000000000000000000000000..8784004e5698866ca8ef78ba9b856797fbd00682 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/ReferenceRegistryValue.java +@@ -0,0 +1,13 @@ ++package io.papermc.paper.registry; ++ ++import net.minecraft.core.Holder; ++import org.jspecify.annotations.NullMarked; ++ ++@NullMarked ++public record ReferenceRegistryValue(Holder.Reference holder) implements RegistryValue.Reference { ++ ++ @Override ++ public TypedKey key() { ++ return PaperRegistries.fromNms(this.holder.key()); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryCreationLookupEventHolder.java b/src/main/java/io/papermc/paper/registry/event/RegistryCreationLookupEventHolder.java +new file mode 100644 +index 0000000000000000000000000000000000000000..7cd783431adf7e6e3c1eda7e3fb5d99b23c2d9aa +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/event/RegistryCreationLookupEventHolder.java +@@ -0,0 +1,35 @@ ++package io.papermc.paper.registry.event; ++ ++import io.papermc.paper.registry.PaperRegistries; ++import io.papermc.paper.registry.ReferenceRegistryValue; ++import io.papermc.paper.registry.RegistryCreationLookup; ++import io.papermc.paper.registry.RegistryValue; ++import io.papermc.paper.registry.TypedKey; ++import io.papermc.paper.registry.data.util.Conversions; ++import io.papermc.paper.registry.set.NamedRegistryKeySetImpl; ++import io.papermc.paper.registry.tag.Tag; ++import io.papermc.paper.registry.tag.TagKey; ++import net.minecraft.core.HolderGetter; ++import net.minecraft.core.HolderSet; ++import net.minecraft.resources.RegistryOps; ++import org.bukkit.Keyed; ++import org.jspecify.annotations.NullMarked; ++ ++@NullMarked ++public interface RegistryCreationLookupEventHolder extends RegistryCreationLookup { ++ ++ Conversions conversions(); ++ ++ @Override ++ default Tag getOrCreateTag(final TagKey tagKey) { ++ final RegistryOps.RegistryInfo registryInfo = this.conversions().lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow(); ++ final HolderSet.Named tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey)); ++ return new NamedRegistryKeySetImpl<>(tagKey, tagSet); ++ } ++ ++ @Override ++ default RegistryValue.Reference getOrCreateValue(final TypedKey typedKey) { ++ final HolderGetter holderGetter = this.conversions().lookup().lookup(PaperRegistries.registryToNms(typedKey.registryKey())).orElseThrow().getter(); ++ return new ReferenceRegistryValue<>(holderGetter.getOrThrow(PaperRegistries.toNms(typedKey))); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java +index cc9c8fd313f530777af80ad79e03903f3f8f9829..cfd63e721e15a982f449f42ff06954982255aa49 100644 +--- a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java ++++ b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java +@@ -1,30 +1,15 @@ + package io.papermc.paper.registry.event; + + import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent; +-import io.papermc.paper.registry.PaperRegistries; + import io.papermc.paper.registry.RegistryBuilder; + import io.papermc.paper.registry.RegistryKey; + import io.papermc.paper.registry.TypedKey; + import io.papermc.paper.registry.data.util.Conversions; +-import io.papermc.paper.registry.set.NamedRegistryKeySetImpl; +-import io.papermc.paper.registry.tag.Tag; +-import io.papermc.paper.registry.tag.TagKey; +-import net.minecraft.core.HolderSet; +-import net.minecraft.resources.RegistryOps; +-import org.bukkit.Keyed; +-import org.checkerframework.checker.nullness.qual.NonNull; + + public record RegistryEntryAddEventImpl>( + TypedKey key, + B builder, + RegistryKey registryKey, + Conversions conversions +-) implements RegistryEntryAddEvent, PaperLifecycleEvent { +- +- @Override +- public @NonNull Tag getOrCreateTag(final TagKey tagKey) { +- final RegistryOps.RegistryInfo registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow(); +- final HolderSet.Named tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey)); +- return new NamedRegistryKeySetImpl<>(tagKey, tagSet); +- } ++) implements RegistryEntryAddEvent, PaperLifecycleEvent, RegistryCreationLookupEventHolder { + } +diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java +index 63957d2509e68ccc6eb2fd9ecaa35bfad7b71b81..94d0dd305b055910f90fa88438a9089fc7715a7e 100644 +--- a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java ++++ b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java +@@ -1,28 +1,13 @@ + package io.papermc.paper.registry.event; + + import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent; +-import io.papermc.paper.registry.PaperRegistries; + import io.papermc.paper.registry.RegistryBuilder; + import io.papermc.paper.registry.RegistryKey; + import io.papermc.paper.registry.data.util.Conversions; +-import io.papermc.paper.registry.set.NamedRegistryKeySetImpl; +-import io.papermc.paper.registry.tag.Tag; +-import io.papermc.paper.registry.tag.TagKey; +-import net.minecraft.core.HolderSet; +-import net.minecraft.resources.RegistryOps; +-import org.bukkit.Keyed; +-import org.checkerframework.checker.nullness.qual.NonNull; + + public record RegistryFreezeEventImpl>( + RegistryKey registryKey, + WritableRegistry registry, + Conversions conversions +-) implements RegistryFreezeEvent, PaperLifecycleEvent { +- +- @Override +- public @NonNull Tag getOrCreateTag(final TagKey tagKey) { +- final RegistryOps.RegistryInfo registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow(); +- final HolderSet.Named tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey)); +- return new NamedRegistryKeySetImpl<>(tagKey, tagSet); +- } ++) implements RegistryFreezeEvent, PaperLifecycleEvent, RegistryCreationLookupEventHolder { + } +diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java +index 46bf2b95658ca3bbd3048df5f8adf1bdcc2d3571..ca9e3a90d0cbdde7a7930f58652ce4bd74ea0db6 100644 +--- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java ++++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java +@@ -130,7 +130,7 @@ public class RegistryDataLoader { + public static RegistryAccess.Frozen load( + ResourceManager resourceManager, List> registries, List> entries + ) { +- return load((loader, infoGetter, conversions) -> loader.loadFromResources(resourceManager, infoGetter, conversions), registries, entries); // Paper - pass conversions ++ return load((loader, infoGetter) -> loader.loadFromResources(resourceManager, infoGetter), registries, entries); + } + + public static RegistryAccess.Frozen load( +@@ -139,7 +139,7 @@ public class RegistryDataLoader { + List> registries, + List> entries + ) { +- return load((loader, infoGetter, conversions) -> loader.loadFromNetwork(data, factory, infoGetter, conversions), registries, entries); // Paper - pass conversions ++ return load((loader, infoGetter) -> loader.loadFromNetwork(data, factory, infoGetter), registries, entries); + } + + private static RegistryAccess.Frozen load( +@@ -148,8 +148,7 @@ public class RegistryDataLoader { + Map, Exception> map = new HashMap<>(); + List> list = entries.stream().map(entry -> entry.create(Lifecycle.stable(), map)).collect(Collectors.toUnmodifiableList()); + RegistryOps.RegistryInfoLookup registryInfoLookup = createContext(registries, list); +- final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(registryInfoLookup); // Paper - create conversions +- list.forEach(loader -> loadable.apply((RegistryDataLoader.Loader)loader, registryInfoLookup, conversions)); ++ list.forEach(loader -> loadable.apply((RegistryDataLoader.Loader)loader, registryInfoLookup)); + list.forEach(loader -> { + Registry registry = loader.registry(); + +@@ -254,12 +253,12 @@ public class RegistryDataLoader { + RegistryOps.RegistryInfoLookup infoGetter, + WritableRegistry registry, + Decoder elementDecoder, +- Map, Exception> errors, +- io.papermc.paper.registry.data.util.Conversions conversions // Paper - pass conversions ++ Map, Exception> errors + ) { + String string = Registries.elementsDirPath(registry.key()); + FileToIdConverter fileToIdConverter = FileToIdConverter.json(string); + RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, infoGetter); ++ final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(infoGetter); // Paper - create conversions + + for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { + ResourceLocation resourceLocation = entry.getKey(); +@@ -287,8 +286,7 @@ public class RegistryDataLoader { + RegistryOps.RegistryInfoLookup infoGetter, + WritableRegistry registry, + Decoder decoder, +- Map, Exception> loadingErrors, +- io.papermc.paper.registry.data.util.Conversions conversions // Paper - pass conversions ++ Map, Exception> loadingErrors + ) { + RegistryDataLoader.NetworkedRegistryData networkedRegistryData = data.get(registry.key()); + if (networkedRegistryData != null) { +@@ -296,6 +294,7 @@ public class RegistryDataLoader { + RegistryOps registryOps2 = RegistryOps.create(JsonOps.INSTANCE, infoGetter); + String string = Registries.elementsDirPath(registry.key()); + FileToIdConverter fileToIdConverter = FileToIdConverter.json(string); ++ final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(infoGetter); // Paper - create conversions + + for (RegistrySynchronization.PackedRegistryEntry packedRegistryEntry : networkedRegistryData.elements) { + ResourceKey resourceKey = ResourceKey.create(registry.key(), packedRegistryEntry.id()); +@@ -327,23 +326,22 @@ public class RegistryDataLoader { + } + + static record Loader(RegistryDataLoader.RegistryData data, WritableRegistry registry, Map, Exception> loadingErrors) { +- public void loadFromResources(ResourceManager resourceManager, RegistryOps.RegistryInfoLookup infoGetter, io.papermc.paper.registry.data.util.Conversions conversions) { // Paper - pass conversions +- RegistryDataLoader.loadContentsFromManager(resourceManager, infoGetter, this.registry, this.data.elementCodec, this.loadingErrors, conversions); // Paper - pass conversions ++ public void loadFromResources(ResourceManager resourceManager, RegistryOps.RegistryInfoLookup infoGetter) { ++ RegistryDataLoader.loadContentsFromManager(resourceManager, infoGetter, this.registry, this.data.elementCodec, this.loadingErrors); + } + + public void loadFromNetwork( + Map>, RegistryDataLoader.NetworkedRegistryData> data, + ResourceProvider factory, +- RegistryOps.RegistryInfoLookup infoGetter, +- io.papermc.paper.registry.data.util.Conversions conversions // Paper ++ RegistryOps.RegistryInfoLookup infoGetter + ) { +- RegistryDataLoader.loadContentsFromNetwork(data, factory, infoGetter, this.registry, this.data.elementCodec, this.loadingErrors, conversions); // Paper - pass conversions ++ RegistryDataLoader.loadContentsFromNetwork(data, factory, infoGetter, this.registry, this.data.elementCodec, this.loadingErrors); + } + } + + @FunctionalInterface + interface LoadingFunction { +- void apply(RegistryDataLoader.Loader loader, RegistryOps.RegistryInfoLookup infoGetter, io.papermc.paper.registry.data.util.Conversions conversions); // Paper - pass conversions ++ void apply(RegistryDataLoader.Loader loader, RegistryOps.RegistryInfoLookup infoGetter); + } + + public static record NetworkedRegistryData(List elements, TagNetworkSerialization.NetworkPayload tags) { +diff --git a/src/main/resources/META-INF/services/io.papermc.paper.registry.RegistryUtilProvider b/src/main/resources/META-INF/services/io.papermc.paper.registry.RegistryUtilProvider +new file mode 100644 +index 0000000000000000000000000000000000000000..a7170f37c03830b8f1432575c127fe2d943b8cf3 +--- /dev/null ++++ b/src/main/resources/META-INF/services/io.papermc.paper.registry.RegistryUtilProvider +@@ -0,0 +1 @@ ++io.papermc.paper.registry.PaperRegistryUtilProvider