Change the ordinal of FMLLoadingPlugin to fix the crash with BetterFps before Minecraft 1.10.2. (#131)

Clean up codes.
This commit is contained in:
ZekerZhayard authored and GitHub committed 2020-12-15 21:17:10 +08:00
1 parent a1b52eb7ac
commit 581a2dddea
13 files changed
+72 -138

No files matched your search

@@ -1,18 +1,28 @@
package customskinloader.forge;
import java.io.File;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Set;
import customskinloader.forge.platform.IFMLPlatform;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class ForgeTweaker implements ITweaker {
public ForgeTweaker() {
try {
IFMLPlatform.FMLPlatformInitializer.initFMLPlatform();
} catch (Exception exception) {
throw new RuntimeException(exception);
private final static String FML_PLATFORM_INITIALIZER = "customskinloader.forge.platform.IFMLPlatform$FMLPlatformInitializer";
@SuppressWarnings("unchecked")
public ForgeTweaker() throws Exception {
// FML is loaded by LaunchClassLoader but we are in AppClassLoader.
if (!this.getClass().getClassLoader().equals(Launch.classLoader)) {
Field field = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions");
field.setAccessible(true);
String exclusionName = this.getClass().getName().substring(0, this.getClass().getName().lastIndexOf("."));
((Set<String>) field.get(Launch.classLoader)).remove(exclusionName);
Launch.classLoader.addTransformerExclusion(exclusionName);
Launch.classLoader.loadClass(FML_PLATFORM_INITIALIZER).getMethod("initFMLPlatform").invoke(null);
}
}