Skip to content

Commit

Permalink
Expand registry prefix omitting filter
Browse files Browse the repository at this point in the history
Fixes #951
  • Loading branch information
Su5eD committed Mar 30, 2024
1 parent d76e419 commit bcca0ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.su5ed.sinytra.connector.mod.compat;

import net.fabricmc.fabric.impl.registry.sync.DynamicRegistriesImpl;
import net.minecraft.resources.ResourceKey;

public class DynamicRegistryPrefixes {
public static boolean isRegisteredFabricDynamicRegistry(ResourceKey<?> key) {
return DynamicRegistriesImpl.FABRIC_DYNAMIC_REGISTRY_KEYS.stream().anyMatch(key::equals);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.su5ed.sinytra.connector.mod.mixin.registries;

import dev.su5ed.sinytra.connector.loader.ConnectorEarlyLoader;
import dev.su5ed.sinytra.connector.mod.compat.DynamicRegistryPrefixes;
import net.minecraft.core.Registry;
import net.minecraft.resources.FileToIdConverter;
import net.minecraft.resources.RegistryDataLoader;
Expand Down Expand Up @@ -70,9 +71,13 @@ private static String modifyRegistryDirPath(ResourceLocation location, RegistryO

@Unique
private static boolean connector$shouldOmitPrefix(ResourceLocation location, ResourceKey<? extends Registry<?>> registryKey, ResourceManager manager) {
String modid = location.getNamespace();
// Fabric mod registries added directly to RegistryDataLoader.WORLDGEN_REGISTRIES should not be prefixed
if (ConnectorEarlyLoader.isConnectorMod(modid) && ModList.get().isLoaded("fabric_registry_sync_v0") && !DynamicRegistryPrefixes.isRegisteredFabricDynamicRegistry(registryKey)) {
return true;
}
// Check if the registry has been registered
if (DataPackRegistriesHooks.getDataPackRegistries().stream().noneMatch(data -> registryKey.equals(data.key()))) {
String modid = location.getNamespace();
// If the namespace is one of a fabric mod, omit the prefix
if (ConnectorEarlyLoader.isConnectorMod(modid)) {
return true;
Expand Down

0 comments on commit bcca0ed

Please sign in to comment.