Minecraft not starting
本文关键字:starting not Minecraft | 更新日期: 2023-09-27 18:29:27
我在一个发射器minecraft的项目中,但没有使用java!只有C#。
我有这段代码,但不知道出了什么问题,只是打开了java,然后关闭了。
public void RunMinecraft()
{
List<string> j_args = new List<string>();
List<string> libraries = new List<string>();
args = "";
int x = Convert.ToInt32(numericUpDown1.Value);
j_args.Add("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump");
j_args.Add("-Xmx" + x + "G");
j_args.Add("-Djava.library.path=" + Application.StartupPath + "''data''natives");
j_args.Add("net.minecraft.client.main.Main");
string lib = Application.StartupPath + "''data''libraries''{0}";
string app = Application.StartupPath;
string game = Application.StartupPath + "''data''game";
string assets = Application.StartupPath + "''data''assets";
#region LIBRARIES
libraries.Add(format2(lib, "oshi-core-1.1.jar"));
libraries.Add(format2(lib, "jna-3.4.0.jar"));
libraries.Add(format2(lib, "platform-3.4.0.jar"));
libraries.Add(format2(lib, "icu4j-core-mojang-51.2.jar"));
libraries.Add(format2(lib, "jopt-simple-4.6.jar"));
libraries.Add(format2(lib, "codecjorbis-20101023.jar"));
libraries.Add(format2(lib, "codecwav-20101023.jar"));
libraries.Add(format2(lib, "libraryjavasound-20101123.jar"));
libraries.Add(format2(lib, "librarylwjglopenal-20100824.jar"));
libraries.Add(format2(lib, "soundsystem-20120107.jar"));
libraries.Add(format2(lib, "netty-all-4.0.23.Final.jar"));
libraries.Add(format2(lib, "guava-17.0.jar"));
libraries.Add(format2(lib, "commons-lang3-3.3.2.jar"));
libraries.Add(format2(lib, "commons-io-2.4.jar"));
libraries.Add(format2(lib, "commons-codec-1.9.jar"));
libraries.Add(format2(lib, "jinput-2.0.5.jar"));
libraries.Add(format2(lib, "jutils-1.0.0.jar"));
libraries.Add(format2(lib, "gson-2.2.4.jar"));
libraries.Add(format2(lib, "authlib-1.5.21.jar"));
libraries.Add(format2(lib, "realms-1.7.48.jar"));
libraries.Add(format2(lib, "httpcore-4.3.2.jar"));
libraries.Add(format2(lib, "log4j-api-2.0-beta9.jar"));
libraries.Add(format2(lib, "log4j-core-2.0-beta9.jar"));
libraries.Add(format3(lib, "1.8.6.jar"));
#endregion
var librariesSTR = "";
var enum0 = libraries.GetEnumerator();
while (enum0.MoveNext())
{
librariesSTR += enum0.Current;
}
j_args.Add("-cp " + librariesSTR);
j_args.Add("--username " + username.Text);
j_args.Add("--accessToken " + accesstoken.Text);
j_args.Add("--userProperties {}");
j_args.Add("--version 1.8.6");
j_args.Add("--gameDir " + game);
var argsSTR = "";
var enum1 = j_args.GetEnumerator();
while (enum1.MoveNext())
{
argsSTR += enum1.Current + " ";
}
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"C:'Program Files'Java'jre7'bin'java.exe";
info.Arguments = args;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = info;
p.OutputDataReceived += P_OutputDataReceived;
info.CreateNoWindow = true;
p.Start();
p.BeginOutputReadLine();
// Clipboard.SetText(argsSTR);
}
private string format3(string a, string b)
{
return string.Format(a, b);
}
#region format2
private string format2(string a, string b)
{
return string.Format(a, b) + ";";
}
#endregion
我使用format2函数使其正确格式化所有库。示例:
libraries.Add("unnamed_lib1.jar"); libraries.Add ("unnamed_lib2.jar");
结果看起来是这样的:
args = "unnamed_lib1.jar;unnamed_lib2.jar;";
以及函数format3(字符串a,字符串b);是以游戏的JAR文件结束的事件。示例:不带";"的"1.8.9.jar"最后
很抱歉拼写错误,因为我不会说太多英语。我正在使用谷歌翻译来帮助我处理文本
我正在使用minecraft的1.8.6版本来启动
将-cp
(类路径)参数放在net.minecraft.client.main.Main
之前,否则它们将被视为应用程序(Main
类)的参数,而不是javaw
可执行文件的参数。
它可能是这样的(我只写了你的一些论点,提交了java.exe,也许还有其他东西):
j_args.Add("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump");
j_args.Add("-Xmx" + x + "G");
j_args.Add("-Djava.library.path=" + Application.StartupPath + "''data''natives");
j_args.Add("-cp " + librariesSTR);
j_args.Add("net.minecraft.client.main.Main");
j_args.Add("--username " + username.Text);
j_args.Add("--accessToken " + accesstoken.Text);
j_args.Add("--userProperties {}");
j_args.Add("--version 1.8.6");
j_args.Add("--gameDir " + game);