blob: 6e4d2ce0b9e41ae03b5a5dd77eb2f90a7820cb17 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
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;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Mixin configuration for CIT Resewn's mixins.
*/
public class CITResewnMixinConfiguration implements IMixinConfigPlugin {
private static final String MIXINS_ROOT = "shcm.shsupercm.fabric.citresewn.mixin";
/**
* Is Broken Paths enabled in config.
* @see BrokenPaths
* @see CITResewnConfig#broken_paths
*/
private boolean broken_paths;
/**
* Slightly modified mod ids for loaded mods and mods with compat mixins.
*/
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
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.startsWith("compat.")) {
mixinClassName = mixinClassName.substring(7);
String modid = mixinClassName.substring(0, mixinClassName.indexOf('.'));
if (mods.contains(modid)) {
if (compatMods.add(modid))
CITResewn.info("Loading compatibility for " + modid);
return true;
}
return false;
}
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) { }
}
|