Skip to content

Instantly share code, notes, and snippets.

@JmPotato
Last active Dec 20, 2015
Embed
What would you like to do?
Minecraft 启动函数
public static void StartGame(string JavaPath, string max_memory, string playername, string version, bool login, string login_parameter)
{
string path = System.Environment.CurrentDirectory;
string command = "";
if (login)
{
if (version == "旧版(1.5.2及以下版本)")
{
command = String.Format("\"{0}\" -Xincgc -Xmx{3}m -cp \"{1}\\.minecraft\\bin\\minecraft.jar;{1}\\.minecraft\\bin\\lwjgl.jar ;{1}\\.minecraft\\bin\\lwjgl_util.jar;{1}\\.minecraft\\bin\\jinput.jar\" -Djava.library.path=\"{1}\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft {2}", JavaPath, path, login_parameter, max_memory);
}
else if (version == "1.6.2")
{
command = String.Format("\"{0}\" -Xincgc -Xmx{1}M -Djava.library.path=\"{2}\\.minecraft\\versions\\1.6.2\\1.6.2-natives\" -cp \"{2}\\.minecraft\\libraries\\net\\sf\\jopt-simple\\jopt-simple\\4.5\\jopt-simple-4.5.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\codecjorbis\\20101023\\codecjorbis-20101023.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\codecwav\\20101023\\codecwav-20101023.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\libraryjavasound\\20101123\\libraryjavasound-20101123.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\librarylwjglopenal\\20100824\\librarylwjglopenal-20100824.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\soundsystem\\20120107\\soundsystem-20120107.jar;{2}\\.minecraft\\libraries\\org\\lwjgl\\lwjgl\\lwjgl\\2.9.0\\lwjgl-2.9.0.jar;{2}\\.minecraft\\libraries\\org\\lwjgl\\lwjgl\\lwjgl_util\\2.9.0\\lwjgl_util-2.9.0.jar;{2}\\.minecraft\\libraries\\argo\\argo\\2.25_fixed\\argo-2.25_fixed.jar;{3}\\.minecraft\\libraries\\org\\bouncycastle\\bcprov-jdk15on\\1.47\\bcprov-jdk15on-1.47.jar;{2}\\.minecraft\\libraries\\com\\google\\guava\\guava\\14.0\\guava-14.0.jar;{2}\\.minecraft\\libraries\\org\\apache\\commons\\commons-lang3\\3.1\\commons-lang3-3.1.jar;{2}\\.minecraft\\libraries\\commons-io\\commons-io\\2.4\\commons-io-2.4.jar;{2}\\.minecraft\\libraries\\net\\java\\jinput\\jinput\\2.0.5\\jinput-2.0.5.jar;{2}\\.minecraft\\libraries\\net\\java\\jutils\\jutils\\1.0.0\\jutils-1.0.0.jar;{2}\\.minecraft\\libraries\\com\\google\\code\\gson\\gson\\2.2.2\\gson-2.2.2.jar;{2}\\.minecraft\\versions\\1.6.2\\1.6.2.jar\" net.minecraft.client.main.Main --{3} --version 1.6.2 --workDir \".minecraft\"", JavaPath, max_memory, path, login_parameter);
}
}
else
{
if (version == "旧版(1.5.2及以下版本)")
{
command = String.Format("\"{0}\" -Xincgc -Xmx{3}m -cp \"{1}\\.minecraft\\bin\\minecraft.jar;{1}\\.minecraft\\bin\\lwjgl.jar;{1}\\.minecraft\\bin\\lwjgl_util.jar;{1}\\.minecraft\\bin\\jinput.jar\" -Djava.library.path=\"{1}\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft {2}", JavaPath, path, playername, max_memory);
}
else if (version == "1.6.2")
{
command = String.Format("\"{0}\" -Xincgc -Xmx{1}M -Djava.library.path=\"{2}\\.minecraft\\versions\\1.6.2\\1.6.2-natives\" -cp \"{2}\\.minecraft\\libraries\\net\\sf\\jopt-simple\\jopt-simple\\4.5\\jopt-simple-4.5.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\codecjorbis\\20101023\\codecjorbis-20101023.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\codecwav\\20101023\\codecwav-20101023.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\libraryjavasound\\20101123\\libraryjavasound-20101123.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\librarylwjglopenal\\20100824\\librarylwjglopenal-20100824.jar;{2}\\.minecraft\\libraries\\com\\paulscode\\soundsystem\\20120107\\soundsystem-20120107.jar;{2}\\.minecraft\\libraries\\org\\lwjgl\\lwjgl\\lwjgl\\2.9.0\\lwjgl-2.9.0.jar;{2}\\.minecraft\\libraries\\org\\lwjgl\\lwjgl\\lwjgl_util\\2.9.0\\lwjgl_util-2.9.0.jar;{2}\\.minecraft\\libraries\\argo\\argo\\2.25_fixed\\argo-2.25_fixed.jar;{3}\\.minecraft\\libraries\\org\\bouncycastle\\bcprov-jdk15on\\1.47\\bcprov-jdk15on-1.47.jar;{2}\\.minecraft\\libraries\\com\\google\\guava\\guava\\14.0\\guava-14.0.jar;{2}\\.minecraft\\libraries\\org\\apache\\commons\\commons-lang3\\3.1\\commons-lang3-3.1.jar;{2}\\.minecraft\\libraries\\commons-io\\commons-io\\2.4\\commons-io-2.4.jar;{2}\\.minecraft\\libraries\\net\\java\\jinput\\jinput\\2.0.5\\jinput-2.0.5.jar;{2}\\.minecraft\\libraries\\net\\java\\jutils\\jutils\\1.0.0\\jutils-1.0.0.jar;{2}\\.minecraft\\libraries\\com\\google\\code\\gson\\gson\\2.2.2\\gson-2.2.2.jar;{2}\\.minecraft\\versions\\1.6.2\\1.6.2.jar\" net.minecraft.client.main.Main --{3} --version 1.6.2 --workDir \".minecraft\"", JavaPath, max_memory, path, playername);
}
}
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("set APPDATA=%CD%");
p.StandardInput.WriteLine(command);
p.StandardInput.WriteLine("exit");
MessageBox.Show("游戏启动中");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment