我的世界无法启动

Minecraft not starting

我在一个启动器 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(string a, string b);是用游戏的 JAR 文件结束的事件。 示例:“1.8.9.jar”没有“;”最后

Sorry for the misspelling because I do not speak much English. And I am using Google translator to help me with the texts.

I'm using the 1.8.6 version of minecraft to start

将您的 -cp (classpath) 参数放在 net.minecraft.client.main.Main 之前,否则它们将被视为应用程序的参数 (Main class),不适用于 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);