diff options
author | SHsuperCM <shsupercm@gmail.com> | 2022-03-17 15:49:35 +0200 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2022-03-17 15:49:35 +0200 |
commit | db592ed372f22e71206a6debab11389898c69f01 (patch) | |
tree | 5eea91a5cecaf45d1a23aaef1df56f9b7811a29d /src/main/java/shcm | |
parent | c33015c87439e563ee953a57765bb7fa639c3b5f (diff) | |
download | CITResewn-db592ed372f22e71206a6debab11389898c69f01.tar.gz CITResewn-db592ed372f22e71206a6debab11389898c69f01.tar.bz2 CITResewn-db592ed372f22e71206a6debab11389898c69f01.zip |
Minor cleanups
Diffstat (limited to 'src/main/java/shcm')
3 files changed, 16 insertions, 9 deletions
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<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; 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")) |