aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnMixinConfiguration.java
blob: 29f64e942ab0edeb96867430053d8911ae8adcc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 java.util.List;
import java.util.Set;

public class CITResewnMixinConfiguration implements IMixinConfigPlugin {
    private static final String MIXINS_ROOT = "shcm.shsupercm.fabric.citresewn.mixin";

    private boolean broken_paths;

    @Override
    public void onLoad(String mixinPackage) {
        CITResewnConfig launchConfig = CITResewnConfig.read();

        this.broken_paths = launchConfig.broken_paths;
    }

    @Override
    public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
        if (!mixinClassName.startsWith(MIXINS_ROOT))
            return false;
        mixinClassName = mixinClassName.substring(MIXINS_ROOT.length() + 1);

        if (mixinClassName.startsWith("broken_paths"))
            return broken_paths;

        if (mixinClassName.equals("GroupResourcePackAccessor"))
            return FabricLoader.getInstance().isModLoaded("fabric-resource-loader-v0");

        return true;
    }


    @Override
    public String getRefMapperConfig() { return null; }
    @Override
    public List<String> getMixins() { return null; }
    @Override
    public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { }
    @Override
    public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { }
    @Override
    public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { }
}