diff --git a/common/src/main/java/dev/architectury/registry/registries/Registrar.java b/common/src/main/java/dev/architectury/registry/registries/Registrar.java index 27865b73..b77146eb 100644 --- a/common/src/main/java/dev/architectury/registry/registries/Registrar.java +++ b/common/src/main/java/dev/architectury/registry/registries/Registrar.java @@ -19,6 +19,7 @@ package dev.architectury.registry.registries; +import com.mojang.serialization.Codec; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -77,6 +78,10 @@ default Holder getHolder(ResourceLocation id) { return getHolder(ResourceKey.create(key(), id)); } + Codec codec(); + + Codec> holderCodec(); + /** * Listens to when the registry entry is registered, and calls the given action. * Evaluates immediately if the entry is already registered. diff --git a/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java b/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java index c3d19516..5453538c 100644 --- a/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java @@ -23,6 +23,7 @@ import com.google.common.base.Suppliers; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import com.mojang.serialization.Codec; import dev.architectury.impl.RegistrySupplierImpl; import dev.architectury.registry.registries.Registrar; import dev.architectury.registry.registries.RegistrarBuilder; @@ -289,6 +290,16 @@ public Holder getHolder(ResourceKey key) { return delegate.getHolder(key).orElse(null); } + @Override + public Codec codec() { + return delegate.byNameCodec(); + } + + @Override + public Codec> holderCodec() { + return delegate.holderByNameCodec(); + } + @Override public Iterator iterator() { return delegate.iterator(); diff --git a/neoforge/src/main/java/dev/architectury/registry/registries/forge/RegistrarManagerImpl.java b/neoforge/src/main/java/dev/architectury/registry/registries/forge/RegistrarManagerImpl.java index 9aec8712..ca0b3764 100644 --- a/neoforge/src/main/java/dev/architectury/registry/registries/forge/RegistrarManagerImpl.java +++ b/neoforge/src/main/java/dev/architectury/registry/registries/forge/RegistrarManagerImpl.java @@ -23,6 +23,7 @@ import com.google.common.base.Suppliers; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import com.mojang.serialization.Codec; import dev.architectury.impl.RegistrySupplierImpl; import dev.architectury.platform.hooks.EventBusesHooks; import dev.architectury.registry.registries.Registrar; @@ -397,6 +398,16 @@ public Holder getHolder(ResourceKey key) { return delegate.getHolder(key).orElse(null); } + @Override + public Codec codec() { + return delegate.byNameCodec(); + } + + @Override + public Codec> holderCodec() { + return delegate.holderByNameCodec(); + } + @Override public Iterator iterator() { return delegate.iterator();