diff options
Diffstat (limited to 'patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch')
-rw-r--r-- | patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch index cd3f10527d..c06dec8fbe 100644 --- a/patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/0481-Add-RegistryAccess-for-managing-Registries.patch @@ -12,10 +12,10 @@ public net.minecraft.server.RegistryLayer STATIC_ACCESS diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java new file mode 100644 -index 0000000000000000000000000000000000000000..4f4595356f2d17c261a84e13d37351f06433177b +index 0000000000000000000000000000000000000000..5b6d0c5c788bfd158494a88665a2b9b8c45a9ffe --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java -@@ -0,0 +1,108 @@ +@@ -0,0 +1,119 @@ +package io.papermc.paper.registry; + +import io.papermc.paper.registry.entry.RegistryEntry; @@ -23,6 +23,7 @@ index 0000000000000000000000000000000000000000..4f4595356f2d17c261a84e13d37351f0 +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; ++import java.util.Objects; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; @@ -121,6 +122,16 @@ index 0000000000000000000000000000000000000000..4f4595356f2d17c261a84e13d37351f0 + return (RegistryEntry<M, T, R>) BY_REGISTRY_KEY.get(registryKey); + } + ++ @SuppressWarnings("unchecked") ++ public static <M, T> RegistryKey<T> fromNms(final ResourceKey<? extends Registry<M>> registryResourceKey) { ++ return (RegistryKey<T>) Objects.requireNonNull(BY_RESOURCE_KEY.get(registryResourceKey), registryResourceKey + " doesn't have an api RegistryKey").apiKey(); ++ } ++ ++ @SuppressWarnings("unchecked") ++ public static <M, T> ResourceKey<? extends Registry<M>> toNms(final RegistryKey<T> registryKey) { ++ return (ResourceKey<? extends Registry<M>>) Objects.requireNonNull(BY_REGISTRY_KEY.get(registryKey), registryKey + " doesn't have an mc registry ResourceKey").mcKey(); ++ } ++ + private PaperRegistries() { + } +} |