From db592ed372f22e71206a6debab11389898c69f01 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Thu, 17 Mar 2022 15:49:35 +0200 Subject: Minor cleanups --- .../shsupercm/fabric/citresewn/CITResewnCommand.java | 4 ++-- .../citresewn/config/CITResewnMixinConfiguration.java | 19 +++++++++++++------ .../compat/lambdabettergrass/PackParserMixin.java | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/main/java/shcm') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java index 6583cd8..e07a772 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java @@ -40,9 +40,9 @@ public class CITResewnCommand { public static boolean openConfig = false; /** - * Registers + * Registers all of CIT Resewn's commands. */ - static void register() { + public static void register() { ClientCommandManager.DISPATCHER.register(literal("citresewn") .executes(context -> { //citresewn context.getSource().sendFeedback(of("CIT Resewn v" + FabricLoader.getInstance().getModContainer("citresewn").orElseThrow().getMetadata().getVersion() + ":")); 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; diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/compat/lambdabettergrass/PackParserMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/compat/lambdabettergrass/PackParserMixin.java index 2e43143..69e432c 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/compat/lambdabettergrass/PackParserMixin.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/compat/lambdabettergrass/PackParserMixin.java @@ -8,7 +8,7 @@ import shcm.shsupercm.fabric.citresewn.pack.PackParser; import java.io.IOException; @SuppressWarnings("UnresolvedMixinReference") -@Mixin(PackParser.class) +@Mixin(value = PackParser.class, remap = false) public class PackParserMixin { @ModifyVariable(method = "loadGlobalProperties(Lnet/minecraft/resource/ResourceManager;Lshcm/shsupercm/fabric/citresewn/pack/GlobalProperties;)Lshcm/shsupercm/fabric/citresewn/pack/GlobalProperties;", at = @At(value = "INVOKE", target = "shcm/shsupercm/fabric/citresewn/CITResewn.logErrorLoading(Ljava/lang/String;)V")) -- cgit