|
1 | 1 | package org.embeddedt.archaicfix; |
2 | 2 |
|
3 | | -import com.google.common.collect.ImmutableMap; |
4 | 3 | import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader; |
| 4 | +import com.gtnewhorizon.gtnhmixins.builders.IMixins; |
5 | 5 | import cpw.mods.fml.relauncher.IFMLLoadingPlugin; |
6 | 6 | import org.apache.logging.log4j.LogManager; |
7 | 7 | import org.apache.logging.log4j.Logger; |
8 | 8 | import org.embeddedt.archaicfix.asm.Mixin; |
9 | | -import org.embeddedt.archaicfix.asm.TargetedMod; |
10 | 9 | import org.embeddedt.archaicfix.asm.transformer.VampirismTransformer; |
11 | 10 | import org.embeddedt.archaicfix.config.ArchaicConfig; |
12 | 11 | import org.embeddedt.archaicfix.config.ConfigException; |
13 | 12 | import org.embeddedt.archaicfix.config.ConfigurationManager; |
14 | 13 | import org.embeddedt.archaicfix.helpers.LetsEncryptHelper; |
15 | 14 |
|
16 | | -import java.util.*; |
17 | | -import java.util.stream.Collectors; |
| 15 | +import java.util.List; |
| 16 | +import java.util.Map; |
| 17 | +import java.util.Set; |
18 | 18 |
|
19 | 19 | @IFMLLoadingPlugin.Name("ArchaicCore") |
20 | 20 | @IFMLLoadingPlugin.MCVersion("1.7.10") |
21 | 21 | public class ArchaicCore implements IFMLLoadingPlugin, IEarlyMixinLoader { |
| 22 | + |
22 | 23 | public static final Logger LOGGER = LogManager.getLogger("ArchaicCore"); |
| 24 | + |
23 | 25 | static { |
24 | 26 | VampirismTransformer.init(); |
25 | 27 | try { |
26 | 28 | ConfigurationManager.registerConfig(ArchaicConfig.class); |
27 | | - } catch(ConfigException e) { |
| 29 | + } catch (ConfigException e) { |
28 | 30 | throw new RuntimeException(e); |
29 | 31 | } |
30 | 32 | LetsEncryptHelper.replaceSSLContext(); |
31 | 33 | } |
| 34 | + |
32 | 35 | @Override |
33 | 36 | public String[] getASMTransformerClass() { |
34 | | - return new String[] { |
35 | | - "org.embeddedt.archaicfix.asm.ArchaicTransformer" |
| 37 | + return new String[]{ |
| 38 | + "org.embeddedt.archaicfix.asm.ArchaicTransformer" |
36 | 39 | }; |
37 | 40 | } |
38 | 41 |
|
@@ -61,38 +64,8 @@ public String getMixinConfig() { |
61 | 64 | return "mixins.archaicfix.early.json"; |
62 | 65 | } |
63 | 66 |
|
64 | | - public static Set<TargetedMod> coreMods = new HashSet<>(); |
65 | | - |
66 | | - private static final ImmutableMap<String, TargetedMod> MODS_BY_CLASS = ImmutableMap.<String, TargetedMod>builder() |
67 | | - .put("optifine.OptiFineForgeTweaker", TargetedMod.OPTIFINE) |
68 | | - .put("fastcraft.Tweaker", TargetedMod.FASTCRAFT) |
69 | | - .put("cofh.asm.LoadingPlugin", TargetedMod.COFHCORE) |
70 | | - .put("com.mitchej123.hodgepodge.core.HodgepodgeCore", TargetedMod.HODGEPODGE) |
71 | | - .build(); |
72 | | - |
73 | | - private static void detectCoreMods(Set<String> loadedCoreMods) { |
74 | | - MODS_BY_CLASS.forEach((key, value) -> { |
75 | | - if (loadedCoreMods.contains(key)) |
76 | | - coreMods.add(value); |
77 | | - }); |
78 | | - } |
79 | | - |
80 | 67 | @Override |
81 | 68 | public List<String> getMixins(Set<String> loadedCoreMods) { |
82 | | - List<String> mixins = new ArrayList<>(); |
83 | | - detectCoreMods(loadedCoreMods); |
84 | | - LOGGER.info("Detected coremods: [{}]", coreMods.stream().map(TargetedMod::name).collect(Collectors.joining(", "))); |
85 | | - final List<String> notLoading = new ArrayList<>(); |
86 | | - |
87 | | - for (Mixin mixin : Mixin.values()) { |
88 | | - if (mixin.getPhase() == Mixin.Phase.EARLY && mixin.shouldLoadSide() && mixin.getFilter().test(coreMods)) { |
89 | | - mixins.add(mixin.getMixin()); |
90 | | - } else { |
91 | | - notLoading.add(mixin.getMixin()); |
92 | | - } |
93 | | - } |
94 | | - |
95 | | - LOGGER.info("Not loading the following early mixins: [{}]", String.join(", ", notLoading)); |
96 | | - return mixins; |
| 69 | + return IMixins.getEarlyMixins(Mixin.class, loadedCoreMods); |
97 | 70 | } |
98 | 71 | } |
0 commit comments