From db592ed372f22e71206a6debab11389898c69f01 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Thu, 17 Mar 2022 15:49:35 +0200 Subject: Minor cleanups --- .../citresewn/config/CITResewnMixinConfiguration.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java index bfabb8f..6e4d2ce 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java @@ -1,6 +1,7 @@ package shcm.shsupercm.fabric.citresewn.config; import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -24,15 +25,18 @@ public class CITResewnMixinConfiguration implements IMixinConfigPlugin { private boolean broken_paths; /** - * Set of mod ids that had compatibility mixins loaded for them. + * Slightly modified mod ids for loaded mods and mods with compat mixins. */ - private Set compatMods = new HashSet<>(); + private final Set mods = new HashSet<>(), compatMods = new HashSet<>(); @Override public void onLoad(String mixinPackage) { CITResewnConfig launchConfig = CITResewnConfig.read(); this.broken_paths = launchConfig.broken_paths; + + for (ModContainer mod : FabricLoader.getInstance().getAllMods()) + mods.add(mod.getMetadata().getId().replace('-', '_')); } @Override @@ -47,10 +51,13 @@ public class CITResewnMixinConfiguration implements IMixinConfigPlugin { if (mixinClassName.startsWith("compat.")) { mixinClassName = mixinClassName.substring(7); String modid = mixinClassName.substring(0, mixinClassName.indexOf('.')); - boolean loaded = FabricLoader.getInstance().isModLoaded(modid); - if (loaded && compatMods.add(modid)) - CITResewn.info("Loading compatibility for " + modid); - return loaded; + if (mods.contains(modid)) { + if (compatMods.add(modid)) + CITResewn.info("Loading compatibility for " + modid); + + return true; + } + return false; } return true; -- cgit