diff options
author | SHsuperCM <shsupercm@gmail.com> | 2022-03-17 05:36:11 +0200 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2022-03-17 05:36:11 +0200 |
commit | c33015c87439e563ee953a57765bb7fa639c3b5f (patch) | |
tree | 6dc76fdece68f4c598614a547d6dcb0dc7a97e8f | |
parent | 08168af5926129733b8f766b6a6eb24b6167fe01 (diff) | |
download | CITResewn-c33015c87439e563ee953a57765bb7fa639c3b5f.tar.gz CITResewn-c33015c87439e563ee953a57765bb7fa639c3b5f.tar.bz2 CITResewn-c33015c87439e563ee953a57765bb7fa639c3b5f.zip |
Set up compat mixin system and moved lbg compat
3 files changed, 43 insertions, 3 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 ca0b149..bfabb8f 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java @@ -1,9 +1,12 @@ package shcm.shsupercm.fabric.citresewn.config; +import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import shcm.shsupercm.fabric.citresewn.CITResewn; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,6 +23,11 @@ public class CITResewnMixinConfiguration implements IMixinConfigPlugin { */ private boolean broken_paths; + /** + * Set of mod ids that had compatibility mixins loaded for them. + */ + private Set<String> compatMods = new HashSet<>(); + @Override public void onLoad(String mixinPackage) { CITResewnConfig launchConfig = CITResewnConfig.read(); @@ -36,6 +44,15 @@ public class CITResewnMixinConfiguration implements IMixinConfigPlugin { if (mixinClassName.startsWith("broken_paths")) return broken_paths; + 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; + } + 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 new file mode 100644 index 0000000..2e43143 --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/compat/lambdabettergrass/PackParserMixin.java @@ -0,0 +1,26 @@ +package shcm.shsupercm.fabric.citresewn.mixin.compat.lambdabettergrass; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import shcm.shsupercm.fabric.citresewn.pack.PackParser; + +import java.io.IOException; + +@SuppressWarnings("UnresolvedMixinReference") +@Mixin(PackParser.class) +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")) + private static IOException citresewn$compat$lambdabettergrass$muteStacktrace(IOException exception) { + if (exception.getMessage().contains("lambdabettergrass")) + return new IOException() { + @Override + public void printStackTrace() { + //no + } + }; + + return exception; + } +} diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java index 72ed57b..9f57760 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java @@ -47,9 +47,6 @@ public final class PackParser { private PackParser() {} globalProperties.load(pack.getName(), identifier, pack.open(ResourceType.CLIENT_RESOURCES, identifier)); } catch (FileNotFoundException ignored) { } catch (IOException e) { - // fixes log spam from Lambda Better Grass todo move to a compat mixin - if (pack.getClass().getSimpleName().equals("LBGResourcePack")) continue; - CITResewn.logErrorLoading("Errored while loading global properties: " + identifier + " from " + pack.getName()); e.printStackTrace(); } |