diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistriesImpl.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistriesImpl.java index dacbb565d6..83c5f41206 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistriesImpl.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistriesImpl.java @@ -35,6 +35,7 @@ public final class DynamicRegistriesImpl { private static final List> DYNAMIC_REGISTRIES = new ArrayList<>(RegistryLoader.DYNAMIC_REGISTRIES); + public static final Set> FABRIC_DYNAMIC_REGISTRY_KEYS = new HashSet<>(); public static final Set>> DYNAMIC_REGISTRY_KEYS = new HashSet<>(); public static final Set>> SKIP_EMPTY_SYNC_REGISTRIES = new HashSet<>(); @@ -61,6 +62,7 @@ public static void register(RegistryKey> key, Codec var entry = new RegistryLoader.Entry<>(key, codec); DYNAMIC_REGISTRIES.add(entry); + FABRIC_DYNAMIC_REGISTRY_KEYS.add(key); } public static void addSyncedRegistry(RegistryKey> registryKey, Codec networkCodec, DynamicRegistries.SyncOption... options) { diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/RegistryLoaderMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/RegistryLoaderMixin.java index 33f93359e3..550b923ade 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/RegistryLoaderMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/RegistryLoaderMixin.java @@ -37,6 +37,7 @@ import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; +import net.fabricmc.fabric.impl.registry.sync.DynamicRegistriesImpl; import net.fabricmc.fabric.impl.registry.sync.DynamicRegistryViewImpl; @Mixin(RegistryLoader.class) @@ -61,11 +62,12 @@ private static void beforeLoad(ResourceManager resourceManager, DynamicRegistryM } // Vanilla doesn't mark namespaces in the directories of dynamic registries at all, - // so we prepend the directories with the namespace if it's a modded registry id. + // so we prepend the directories with the namespace if it's a modded registry registered using the Fabric API. @Inject(method = "getPath", at = @At("RETURN"), cancellable = true) private static void prependDirectoryWithNamespace(Identifier id, CallbackInfoReturnable info) { - if (!id.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { - String newPath = id.getNamespace() + "/" + info.getReturnValue(); + if (!id.getNamespace().equals(Identifier.DEFAULT_NAMESPACE) + && DynamicRegistriesImpl.FABRIC_DYNAMIC_REGISTRY_KEYS.contains(RegistryKey.ofRegistry(id))) { + final String newPath = id.getNamespace() + "/" + info.getReturnValue(); info.setReturnValue(newPath); } }