aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-03-17 15:49:35 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-03-17 15:49:35 +0200
commitdb592ed372f22e71206a6debab11389898c69f01 (patch)
tree5eea91a5cecaf45d1a23aaef1df56f9b7811a29d /src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java
parentc33015c87439e563ee953a57765bb7fa639c3b5f (diff)
downloadCITResewn-db592ed372f22e71206a6debab11389898c69f01.tar.gz
CITResewn-db592ed372f22e71206a6debab11389898c69f01.tar.bz2
CITResewn-db592ed372f22e71206a6debab11389898c69f01.zip
Minor cleanups
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java19
1 files changed, 13 insertions, 6 deletions
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<String> compatMods = new HashSet<>();
+ private final Set<String> 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;