我想在VB.Net中为我和我的朋友创建自己的Minecraft Launcher。我有此代码,该代码为我提供了访问令牌。

Private ACCESS_TOKEN As String
Public Function GetAccessToken() As String
    Return ACCESS_TOKEN
End Function
Public Sub ObtainAccessToken()
    Dim username As String = TextBox1.Text
    Dim password As String = TextBox2.Text
    Dim UUID As String = Guid.NewGuid.ToString()
    Dim httpWebRequest = DirectCast(WebRequest.Create("https://authserver.mojang.com/authenticate"), HttpWebRequest)
    httpWebRequest.ContentType = "application/json"
    httpWebRequest.Method = "POST"

    Using streamWriter = New StreamWriter(httpWebRequest.GetRequestStream())
        Dim json As String = (Convert.ToString((Convert.ToString("{""agent"":{""name"":""Minecraft"",""version"":1},""username"":""") & username) + """,""password"":""") & password) + """,""clientToken"":" & ControlChars.Quote & UUID & ControlChars.Quote & "}"

        streamWriter.Write(json)
        streamWriter.Flush()
        streamWriter.Close()

        Dim httpResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
        Using streamReader = New StreamReader(httpResponse.GetResponseStream())
            Dim result = streamReader.ReadToEnd()
            ACCESS_TOKEN = result
        End Using
    End Using
End Sub


但是该访问令牌怎么办?如何直接使用Java参数启动minecraft?我想启动minecraft.jar文件。

最佳答案

在.minecraft文件夹中,所有参数都在version.json中

这是1.8.8版(.minecraft / versons / 1.8.8)中json的片段

"id": "1.8.8",
"time": "2016-06-01T07:45:48-04:00",
"releaseTime": "2015-07-27T06:31:28-04:00",
"type": "release",
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userProperties ${user_properties} --userType ${user_type}"


args位于“ minecraftArguments”下,而jar文件位于名为1.8.8.jar的同一目录中。

10-08 18:51