From 2b70b17e6a556fd832cfbf85d9e6985c25c108fe Mon Sep 17 00:00:00 2001 From: Dennis C Date: Sat, 23 Dec 2023 18:19:06 +0100 Subject: [PATCH] Fix inconsistency between custom registry ID getters and the vanilla one (#414) --- patches/net/minecraft/core/MappedRegistry.java.patch | 4 ++-- .../neoforge/registries/IRegistryExtension.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/patches/net/minecraft/core/MappedRegistry.java.patch b/patches/net/minecraft/core/MappedRegistry.java.patch index 9652fd6758..070cf35113 100644 --- a/patches/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/net/minecraft/core/MappedRegistry.java.patch @@ -162,12 +162,12 @@ + + @Override + public int getId(ResourceLocation name) { -+ return toId.getOrDefault(get(name), -1); ++ return getId(get(name)); + } + + @Override + public int getId(ResourceKey key) { -+ return toId.getOrDefault(get(key), -1); ++ return getId(get(key)); + } + + @Override diff --git a/src/main/java/net/neoforged/neoforge/registries/IRegistryExtension.java b/src/main/java/net/neoforged/neoforge/registries/IRegistryExtension.java index 9faad1ed79..e3b8dc2722 100644 --- a/src/main/java/net/neoforged/neoforge/registries/IRegistryExtension.java +++ b/src/main/java/net/neoforged/neoforge/registries/IRegistryExtension.java @@ -92,20 +92,20 @@ default > void addCallback(Class type, C callba ResourceKey resolve(ResourceKey key); /** - * Gets the integer id linked to the given key. + * Gets the integer id linked to the given key. If the key is not present in the registry, the default entry's + * integer id is returned if the registry is defaulted or {@code -1} if the registry is not defaulted * * @param key the resource key to lookup - * @return the integer id linked to the given key, - * or {@code -1} if the key is not present in this registry + * @return the integer id linked to the given key */ int getId(ResourceKey key); /** - * Gets the integer id linked to the given name. + * Gets the integer id linked to the given name. If the name is not present in the registry, the default entry's + * integer id is returned if the registry is defaulted or {@code -1} if the registry is not defaulted * * @param name the resource name to lookup - * @return the integer id linked to the given name, - * or {@code -1} if the name is not present in this registry + * @return the integer id linked to the given name */ int getId(ResourceLocation name);