mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Add registry-related argument types (#10770)
* Add registry-related argument types * fix tests
This commit is contained in:
@@ -23,6 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+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..00000000000000000000000000000000
|
||||
+ 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() {
|
||||
+ }
|
||||
+}
|
||||
|
Reference in New Issue
Block a user