mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 01:44:24 +00:00
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:
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user