diff --git a/common/src/main/java/juuxel/adorn/lib/registry/Registered.java b/common/src/main/java/juuxel/adorn/lib/registry/Registered.java index b018d7a97..edc517869 100644 --- a/common/src/main/java/juuxel/adorn/lib/registry/Registered.java +++ b/common/src/main/java/juuxel/adorn/lib/registry/Registered.java @@ -1,7 +1,9 @@ package juuxel.adorn.lib.registry; +import net.minecraft.registry.RegistryKey; + import java.util.function.Supplier; -@FunctionalInterface public interface Registered extends Supplier { + RegistryKey key(); } diff --git a/common/src/main/java/juuxel/adorn/lib/registry/RegisteredMap.java b/common/src/main/java/juuxel/adorn/lib/registry/RegisteredMap.java index ff751ca8b..9d0b11b15 100644 --- a/common/src/main/java/juuxel/adorn/lib/registry/RegisteredMap.java +++ b/common/src/main/java/juuxel/adorn/lib/registry/RegisteredMap.java @@ -10,7 +10,7 @@ import java.util.function.Supplier; import java.util.stream.Stream; -public final class RegisteredMap implements Registered> { +public final class RegisteredMap implements Supplier> { private final Map> map; private final Supplier> builtMap; diff --git a/fabric/src/main/java/juuxel/adorn/platform/fabric/RegistrarImpl.java b/fabric/src/main/java/juuxel/adorn/platform/fabric/RegistrarImpl.java index f277b4ee6..135489d9d 100644 --- a/fabric/src/main/java/juuxel/adorn/platform/fabric/RegistrarImpl.java +++ b/fabric/src/main/java/juuxel/adorn/platform/fabric/RegistrarImpl.java @@ -4,6 +4,7 @@ import juuxel.adorn.lib.registry.Registered; import juuxel.adorn.lib.registry.Registrar; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import java.util.ArrayList; import java.util.Iterator; @@ -20,9 +21,20 @@ public RegistrarImpl(Registry registry) { @Override public Registered register(String id, Supplier provider) { - var registered = Registry.register(registry, AdornCommon.id(id), provider.get()); + var key = RegistryKey.of(registry.getKey(), AdornCommon.id(id)); + var registered = Registry.register(registry, key, provider.get()); objects.add(registered); - return () -> registered; + return new Registered<>() { + @Override + public U get() { + return registered; + } + + @Override + public RegistryKey key() { + return key; + } + }; } @Override diff --git a/forge/src/main/java/juuxel/adorn/platform/forge/registrar/DeferredRegistrar.java b/forge/src/main/java/juuxel/adorn/platform/forge/registrar/DeferredRegistrar.java index 2600a262a..4982cd885 100644 --- a/forge/src/main/java/juuxel/adorn/platform/forge/registrar/DeferredRegistrar.java +++ b/forge/src/main/java/juuxel/adorn/platform/forge/registrar/DeferredRegistrar.java @@ -6,6 +6,7 @@ import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.common.extensions.IHolderExtension; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; @@ -31,7 +32,17 @@ public void hook(IEventBus modBus) { public Registered register(String id, Supplier provider) { var registryObject = register.register(id, provider); objects.add(registryObject); - return registryObject::get; + return new Registered<>() { + @Override + public RegistryKey key() { + return ((IHolderExtension) registryObject).getKey(); + } + + @Override + public U get() { + return registryObject.get(); + } + }; } @Override