当前位置: 首页 > 知识库问答 >
问题:

使用C#启动Minecraft 1.8.3

萧越泽
2023-03-14

我目前正在尝试为我的服务器制作一个minecraft启动器。但由于某种原因它无法启动。这是我使用的代码。有人能检查我做错了什么吗?

string installPath = GetJavaInstallationPath();
string filePath = System.IO.Path.Combine(installPath, "bin\\Javaw.exe");

Environment.SetEnvironmentVariable("APPDATA", "C:\\SCO\\");

Process process = new Process();
ProcessStartInfo info = new ProcessStartInfo();
string dir = @"C:\SCO\.minecraft\versions\";
info.FileName = filePath;
info.CreateNoWindow = true;
info.Arguments = "-cp \"" + dir + "1.8.3.jar;" + dir + "lwjgl.jar;" + dir + "lwjgl_util.jar;" + dir + "jinput.jar;\" ";
info.Arguments += "\"-Djava.library.path=" + dir + "natives\" -Xmx1024M -Xms512M net.minecraft.client.main.Main " + username + " " + session;
process.StartInfo = info;
process.Start();

共有2个答案

游安康
2023-03-14

必须尝试此:信息。CreateNoWindow=真;至信息。CreateNoWindow=false;

或重新检查参数,必须Java路径有效

施海
2023-03-14

试试这个代码,它对我有用

private void StartMinecraft(string username, string accessToken, string uuid, string gameVersion)
    {
        ProcessStartInfo minecraft = new ProcessStartInfo
        {
            FileName = GetJavaInstallationPath() + @"\bin\javaw.exe",
            CreateNoWindow = false,
            Arguments = " -XX:+UseConcMarkSweepGC -XX:-UseAdaptiveSizePolicy -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseCMSInitiatingOccupancyOnly -Xmx1024M -Dfile.encoding=UTF-8 -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Djava.library.path=C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/versions/" + gameVersion + "/natives -Dminecraft.launcher.brand=java-minecraft-launcher -Dminecraft.launcher.version=1.6.84-j -cp C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/ibm/icu/icu4j/66.1/icu4j-66.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/javabridge/1.0.22/javabridge-1.0.22.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/io/netty/netty-all/4.1.25.Final/netty-all-4.1.25.Final.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/google/guava/guava/21.0/guava-21.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-io/commons-io/2.5/commons-io-2.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-codec/commons-codec/1.10/commons-codec-1.10.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/brigadier/1.0.17/brigadier-1.0.17.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/datafixerupper/4.0.26/datafixerupper-4.0.26.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/it/unimi/dsi/fastutil/8.2.1/fastutil-8.2.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl/3.2.2/lwjgl-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-jemalloc/3.2.2/lwjgl-jemalloc-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-openal/3.2.2/lwjgl-openal-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-opengl/3.2.2/lwjgl-opengl-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-glfw/3.2.2/lwjgl-glfw-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-stb/3.2.2/lwjgl-stb-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-tinyfd/3.2.2/lwjgl-tinyfd-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/text2speech/1.11.3/text2speech-1.11.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/by/ely/authlib/2.0.27.4/authlib-2.0.27.4.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/versions/" + gameVersion + "/" + gameVersion + ".jar net.minecraft.client.main.Main --username " + username + " --version " + gameVersion + " --gameDir C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft --assetsDir C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/assets --assetIndex " + gameVersion + " --uuid " + uuid + " --accessToken " + accessToken + " --userType legacy --versionType release --width 925 --height 530"
        };
        Process.Start(minecraft);
    }
 类似资料:
  • 我目前正在开发一个自定义的Minecraft 1.6.4启动器。我已经编写了大部分代码是C#,但是我正在批量编写最后一段代码。 这似乎可以启动minecraft 1.5.2 jar (C#计算会话ID(%~ 3)) 然而,在minecraft 1.6.4中,我得到了一个错误: 我听说雷舰的发射方式发生了变化,我是否需要在我的发射器中安装新系统? 如果有一种方法可以在没有批处理的情况下做到这一点,那

  • 问题内容: 如果运行以下命令,Redis会正确启动: 我添加了我的启动脚本: 但是,当我从全新启动中启动时,Redis无法运行。我应该在哪里解决此问题? 问题答案: 这个东西通常设置为20。现在,redis需要联网还为时过早。 因此,请尝试以下操作:

  • 问题内容: 我想在这里做些奇怪的事情。我需要从一个守护进程启动一个logcat进程,该守护进程将在后台运行并打印到终端,而无需控制stdin。它是用于记录日志的,因此理想情况下logcat将打印日志消息,同时仍允许用户输入标准命令并从Shell初始化程序。这是到目前为止我拥有的守护程序的代码。该程序logcat启动并显示日志消息,但由于该程序已控制了stdin,因此我无法在stdin中输入任何命令

  • 问题内容: 在过去的两天里,我一直在尝试找到一种使用其他配置文件启动Chrome的方法,但无济于事。不管我做什么,Selenium为chrome加载的配置文件始终是一些临时配置文件,例如“ C:\ Users \ DARKBO〜1 \ AppData \ Local \ Temp \ scoped_dir14308_25046 \ Default” 我尝试了以下代码: 首先,我尝试直接从Chrom

  • 我尝试使用软件。 使用java-8-openjdk-amd64和 发现了不同的bug,但使用oracle-java8-jdk-amd64则没有。 我正在尝试用这个选项来解决: install4j_java_home_override=/usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin 在位于的sh脚本中,但它不起作用。 我可以选择第三个备选方案(Oracle)并

  • 我在使用SimplesamlPHP实现IdP发起的登录时遇到了麻烦。了解我必须从留档中做什么并不是最容易的事情。 我将用户重定向到IdP服务器,登录后,服务器向SP发送一个XML文件,其中包含电子邮件用户的地址、ID和其他数据。这看起来像是一次成功的登录,但是此时我不知道如何处理这个XML。我应该自己解析它还是使用simplesaml?我如何验证签名? 以下是我收到的XML: