我想在 VB.Net 中为我和我的 friend 创建我自己的 Minecraft 启动器。我有这段代码,它为我提供了访问 token 。
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
但是我可以用这个访问 token 做什么?如何使用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}"
参数位于“minecraftArguments”下,jar 文件位于同一目录中,名为 1.8.8.jar。