|
1 | 1 | package de.pilz.alternativechunkloading.mixins; |
2 | 2 |
|
3 | | -import java.util.List; |
4 | 3 | import java.util.function.Supplier; |
5 | 4 |
|
6 | | -import com.gtnewhorizon.gtnhlib.mixin.IMixins; |
7 | | -import com.gtnewhorizon.gtnhlib.mixin.ITargetedMod; |
8 | | -import com.gtnewhorizon.gtnhlib.mixin.MixinBuilder; |
9 | | -import com.gtnewhorizon.gtnhlib.mixin.Phase; |
10 | | -import com.gtnewhorizon.gtnhlib.mixin.Side; |
11 | | -import com.gtnewhorizon.gtnhlib.mixin.TargetedMod; |
| 5 | +import com.gtnewhorizon.gtnhmixins.builders.IMixins; |
| 6 | +import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder; |
12 | 7 |
|
13 | 8 | import de.pilz.alternativechunkloading.configuration.ConfigBetterChunkloading; |
14 | 9 | import de.pilz.alternativechunkloading.configuration.ConfigFixes; |
15 | 10 |
|
16 | 11 | public enum Mixins implements IMixins { |
17 | 12 |
|
18 | | - VANILLA_MODIFY_FIX_STRUCTURE_GENERATION( |
19 | | - new MixinBuilder("Modifies provideChunk to block unallowed requests.").addTargetedMod(TargetedMod.VANILLA) |
20 | | - .setSide(Side.BOTH) |
21 | | - .setPhase(Phase.EARLY) |
22 | | - .setApplyIf(() -> ConfigBetterChunkloading.enable && ConfigBetterChunkloading.disableForPopulation) |
23 | | - .addMixinClasses("minecraft.MixinChunkProviderServer", "minecraft.MixinChunk")), |
24 | | - VANILLA_FIX_NETHER_PORTAL_GENERATION( |
25 | | - new MixinBuilder("Fix nether portal generation").addTargetedMod(TargetedMod.VANILLA) |
26 | | - .setSide(Side.BOTH) |
27 | | - .setPhase(Phase.EARLY) |
28 | | - .setApplyIf(() -> ConfigFixes.fixVanillaNetherPortalGeneration) |
29 | | - .addMixinClasses("minecraft.MixinTeleporter")), |
30 | | - EREBUS_FIX_EREBUS_NULL_CHECKS(new MixinBuilder("Add missing null checks").addTargetedMod(TargetedModEx.THEEREBUS) |
31 | | - .setSide(Side.BOTH) |
32 | | - .setPhase(Phase.LATE) |
33 | | - .setApplyIf(() -> ConfigFixes.fixErebusNullChecks) |
34 | | - .addMixinClasses("erebus.MixinSpawnerErebus")), |
35 | | - EREBUS_FIX_DIMDOORS_COMPAT( |
36 | | - new MixinBuilder("Add compatibility with Dimensional Doors").addTargetedMod(TargetedModEx.DIMDOORS) |
37 | | - .setSide(Side.BOTH) |
38 | | - .setPhase(Phase.LATE) |
39 | | - .setApplyIf(() -> ConfigFixes.fixDimDoorsCompatibility) |
40 | | - .addMixinClasses( |
41 | | - "dimdoors.modern.MixinChunkBlockSetter", |
42 | | - "dimdoors.modern.MixinDungeonSchematic", |
43 | | - "dimdoors.modern.MixinWorldBlockSettings", |
44 | | - "dimdoors.modern.MixinPocketBuilder")), |
45 | | - EREBUS_FIX_DIMDOORS_LEGACY_COMPAT( |
46 | | - new MixinBuilder("Add compatibility with Dimensional Doors").addTargetedMod(TargetedModEx.DIMDOORS) |
47 | | - .setSide(Side.BOTH) |
48 | | - .setPhase(Phase.LATE) |
49 | | - .setApplyIf(() -> ConfigFixes.fixDimDoorsCompatibility) |
50 | | - .addMixinClasses( |
51 | | - "dimdoors.legacy.MixinChunkBlockSetter", |
52 | | - "dimdoors.legacy.MixinDungeonSchematic", |
53 | | - "dimdoors.legacy.MixinWorldBlockSettings", |
54 | | - "dimdoors.legacy.MixinPocketBuilder")); |
55 | | - |
56 | | - private final List<String> mixinClasses; |
57 | | - private final Supplier<Boolean> applyIf; |
58 | | - private final Phase phase; |
59 | | - private final Side side; |
60 | | - private final List<ITargetedMod> targetedMods; |
61 | | - private final List<ITargetedMod> excludedMods; |
62 | | - |
63 | | - Mixins(MixinBuilder builder) { |
64 | | - this.mixinClasses = builder.mixinClasses; |
65 | | - this.applyIf = builder.applyIf; |
66 | | - this.side = builder.side; |
67 | | - this.targetedMods = builder.targetedMods; |
68 | | - this.excludedMods = builder.excludedMods; |
69 | | - this.phase = builder.phase; |
70 | | - if (this.targetedMods.isEmpty()) { |
71 | | - throw new RuntimeException("No targeted mods specified for " + this.name()); |
72 | | - } |
73 | | - if (this.applyIf == null) { |
74 | | - throw new RuntimeException("No ApplyIf function specified for " + this.name()); |
75 | | - } |
76 | | - } |
77 | | - |
78 | | - public List<String> getMixinClasses() { |
79 | | - return mixinClasses; |
80 | | - } |
81 | | - |
82 | | - public Supplier<Boolean> getApplyIf() { |
83 | | - return applyIf; |
| 13 | + VANILLA_MODIFY_FIX_STRUCTURE_GENERATION(Side.COMMON, Phase.EARLY, |
| 14 | + () -> ConfigBetterChunkloading.enable && ConfigBetterChunkloading.disableForPopulation, |
| 15 | + "minecraft.MixinChunkProviderServer", "minecraft.MixinChunk"), |
| 16 | + VANILLA_FIX_NETHER_PORTAL_GENERATION(Side.COMMON, Phase.EARLY, () -> ConfigFixes.fixVanillaNetherPortalGeneration, |
| 17 | + "minecraft.MixinTeleporter"), |
| 18 | + EREBUS_FIX_EREBUS_NULL_CHECKS(Side.COMMON, Phase.LATE, () -> ConfigFixes.fixErebusNullChecks, |
| 19 | + "erebus.MixinSpawnerErebus"), |
| 20 | + EREBUS_FIX_DIMDOORS_COMPAT(Side.COMMON, Phase.LATE, () -> ConfigFixes.fixDimDoorsCompatibility, |
| 21 | + "dimdoors.modern.MixinChunkBlockSetter", "dimdoors.modern.MixinDungeonSchematic", |
| 22 | + "dimdoors.modern.MixinWorldBlockSettings", "dimdoors.modern.MixinPocketBuilder"), |
| 23 | + EREBUS_FIX_DIMDOORS_LEGACY_COMPAT(Side.COMMON, Phase.LATE, () -> ConfigFixes.fixDimDoorsCompatibility, |
| 24 | + "dimdoors.legacy.MixinChunkBlockSetter", "dimdoors.legacy.MixinDungeonSchematic", |
| 25 | + "dimdoors.legacy.MixinWorldBlockSettings", "dimdoors.legacy.MixinPocketBuilder"); |
| 26 | + |
| 27 | + private final MixinBuilder builder; |
| 28 | + |
| 29 | + Mixins(Side side, Phase phase, String... mixins) { |
| 30 | + builder = new MixinBuilder().addSidedMixins(side, mixins) |
| 31 | + .setPhase(phase); |
84 | 32 | } |
85 | 33 |
|
86 | | - public Phase getPhase() { |
87 | | - return phase; |
| 34 | + Mixins(Side side, Phase phase, Supplier<Boolean> applyIf, String... mixins) { |
| 35 | + builder = new MixinBuilder().addSidedMixins(side, mixins) |
| 36 | + .setPhase(phase) |
| 37 | + .setApplyIf(applyIf); |
88 | 38 | } |
89 | 39 |
|
90 | | - public Side getSide() { |
91 | | - return side; |
| 40 | + @Override |
| 41 | + public MixinBuilder getBuilder() { |
| 42 | + return builder; |
92 | 43 | } |
93 | | - |
94 | | - public List<ITargetedMod> getTargetedMods() { |
95 | | - return targetedMods; |
96 | | - } |
97 | | - |
98 | | - public List<ITargetedMod> getExcludedMods() { |
99 | | - return excludedMods; |
100 | | - } |
101 | | - |
102 | 44 | } |
0 commit comments