Fix DefaultFMLPlatform can't be loaded when other FML platform being used. (#132)

This commit is contained in:
ZekerZhayard authored and GitHub committed 2020-12-20 01:02:07 +08:00
1 parent 581a2dddea
commit 855131d1aa
5 files changed
+51 -32

No files matched your search

@@ -5,11 +5,14 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.Set;
import customskinloader.Logger;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class ForgeTweaker implements ITweaker {
public static Logger logger = new Logger(new File("./CustomSkinLoader/ForgePlugin.log"));
private final static String FML_PLATFORM_INITIALIZER = "customskinloader.forge.platform.IFMLPlatform$FMLPlatformInitializer";
@SuppressWarnings("unchecked")
@@ -21,6 +24,7 @@ public class ForgeTweaker implements ITweaker {
String exclusionName = this.getClass().getName().substring(0, this.getClass().getName().lastIndexOf("."));
((Set<String>) field.get(Launch.classLoader)).remove(exclusionName);
Launch.classLoader.addClassLoaderExclusion(Logger.class.getName());
Launch.classLoader.addTransformerExclusion(exclusionName);
Launch.classLoader.loadClass(FML_PLATFORM_INITIALIZER).getMethod("initFMLPlatform").invoke(null);
}