Skip to content

Commit 4cbda7a

Browse files
committed
make the check more resilient in case the transformer is blocked
1 parent 4b3fc3c commit 4cbda7a

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/main/java/com/falsepattern/lib/internal/FalsePatternLib.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
*/
2121
package com.falsepattern.lib.internal;
2222

23+
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2324
import com.falsepattern.lib.internal.proxy.CommonProxy;
2425

26+
import cpw.mods.fml.common.Loader;
2527
import cpw.mods.fml.common.Mod;
2628
import cpw.mods.fml.common.SidedProxy;
2729
import cpw.mods.fml.common.event.FMLConstructionEvent;
@@ -64,6 +66,9 @@ public void preInit(FMLPreInitializationEvent e) {
6466

6567
@Mod.EventHandler
6668
public void postInit(FMLPostInitializationEvent e) {
69+
if (Loader.isModLoaded("gasstation")) {
70+
CoreLoadingPlugin.validateGasStation();
71+
}
6772
proxy.postInit(e);
6873
}
6974

src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
import java.util.Map;
3434

35+
import static com.falsepattern.lib.mixin.MixinInfo.isClassPresentSafe;
36+
3537
/**
3638
* Coremod stub so that forge loads the jar early
3739
*/
@@ -103,6 +105,18 @@ private static Error skillIssue(String message) {
103105
return skillIssue;
104106
}
105107

108+
public static void validateGasStation() {
109+
//Make sure everything is loaded correctly, crash if gasstation is bugged
110+
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
111+
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
112+
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
113+
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
114+
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
115+
) {
116+
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
117+
}
118+
}
119+
106120
@Override
107121
public String[] getASMTransformerClass() {
108122
return new String[]{Tags.GROUPNAME + ".internal.asm.FPTransformer"};

src/main/java/com/falsepattern/lib/internal/asm/GasStationValidatorTransformer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,7 @@ public String getName() {
3535
@Override
3636
public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) {
3737
if (transformedName.equals("com.falsepattern.gasstation.GasStation")) {
38-
//Make sure everything is loaded correctly, crash if gasstation is bugged
39-
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
40-
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
41-
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
42-
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
43-
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
44-
) {
45-
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
46-
}
38+
CoreLoadingPlugin.validateGasStation();
4739
}
4840
return false;
4941
}

0 commit comments

Comments
 (0)