mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
119 lines
4.0 KiB
Java
119 lines
4.0 KiB
Java
/*
|
|
* Forge Mod Loader
|
|
* Copyright (c) 2012-2013 cpw.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Lesser Public License v2.1
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
*
|
|
* Contributors:
|
|
* cpw - implementation
|
|
*/
|
|
|
|
package cpw.mods.fml.relauncher;
|
|
|
|
import java.applet.Applet;
|
|
import java.io.File;
|
|
import java.lang.reflect.Method;
|
|
import java.net.URLClassLoader;
|
|
import java.util.logging.Level;
|
|
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JOptionPane;
|
|
|
|
import com.google.common.base.Throwables;
|
|
|
|
import cpw.mods.fml.common.launcher.FMLTweaker;
|
|
|
|
import net.minecraft.launchwrapper.LaunchClassLoader;
|
|
|
|
public class FMLLaunchHandler
|
|
{
|
|
private static FMLLaunchHandler INSTANCE;
|
|
static Side side;
|
|
private LaunchClassLoader classLoader;
|
|
private FMLTweaker tweaker;
|
|
private File minecraftHome;
|
|
|
|
public static void configureForClientLaunch(LaunchClassLoader loader, FMLTweaker tweaker)
|
|
{
|
|
instance(loader, tweaker).setupClient();
|
|
}
|
|
|
|
public static void configureForServerLaunch(LaunchClassLoader loader, FMLTweaker tweaker)
|
|
{
|
|
instance(loader, tweaker).setupServer();
|
|
}
|
|
|
|
private static FMLLaunchHandler instance(LaunchClassLoader launchLoader, FMLTweaker tweaker)
|
|
{
|
|
if (INSTANCE == null)
|
|
{
|
|
INSTANCE = new FMLLaunchHandler(launchLoader, tweaker);
|
|
}
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
private FMLLaunchHandler(LaunchClassLoader launchLoader, FMLTweaker tweaker)
|
|
{
|
|
this.classLoader = launchLoader;
|
|
this.tweaker = tweaker;
|
|
this.minecraftHome = tweaker.getGameDir();
|
|
this.classLoader.addClassLoaderExclusion("cpw.mods.fml.relauncher.");
|
|
this.classLoader.addClassLoaderExclusion("net.minecraftforge.classloading.");
|
|
this.classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers.deobf.");
|
|
this.classLoader.addTransformerExclusion("cpw.mods.fml.common.patcher.");
|
|
}
|
|
|
|
private void showWindow(boolean showIt)
|
|
{
|
|
if (CoreModManager.downloadMonitor != null) { return; }
|
|
CoreModManager.downloadMonitor = new DummyDownloader();
|
|
}
|
|
|
|
private void setupClient()
|
|
{
|
|
showWindow(true);
|
|
FMLRelaunchLog.logFileNamePattern = "ForgeModLoader-client-%g.log";
|
|
side = Side.CLIENT;
|
|
setupHome();
|
|
}
|
|
|
|
private void setupServer()
|
|
{
|
|
showWindow(false);
|
|
FMLRelaunchLog.logFileNamePattern = "ForgeModLoader-server-%g.log";
|
|
side = Side.SERVER;
|
|
setupHome();
|
|
|
|
}
|
|
|
|
private void setupHome()
|
|
{
|
|
FMLInjectionData.build(minecraftHome, classLoader);
|
|
FMLRelaunchLog.minecraftHome = minecraftHome;
|
|
FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor,
|
|
FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion);
|
|
FMLRelaunchLog.info("Java is %s, version %s, running on %s:%s:%s, installed at %s", System.getProperty("java.vm.name"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version"), System.getProperty("java.home"));
|
|
FMLRelaunchLog.fine("Java classpath at launch is %s", System.getProperty("java.class.path"));
|
|
FMLRelaunchLog.fine("Java library path at launch is %s", System.getProperty("java.library.path"));
|
|
|
|
try
|
|
{
|
|
CoreModManager.handleLaunch(minecraftHome, classLoader);
|
|
}
|
|
catch (Throwable t)
|
|
{
|
|
t.printStackTrace();
|
|
FMLRelaunchLog.log(Level.SEVERE, t, "An error occurred trying to configure the minecraft home at %s for Forge Mod Loader", minecraftHome.getAbsolutePath());
|
|
throw Throwables.propagate(t);
|
|
}
|
|
}
|
|
|
|
public static Side side()
|
|
{
|
|
return side;
|
|
}
|
|
}
|