Difference between revisions of "Launching the game"

From wiki.vg
Jump to navigation Jump to search
(Created page with "Once the launcher has authenticated the user and downloaded the game, its next task is to start it. For this, it requires a few informations found in the Game_files|version...")
 
(Added and updated argument information based on my experiences creating a Minecraft launcher)
 
(20 intermediate revisions by 9 users not shown)
Line 1: Line 1:
Once the launcher has authenticated the user and downloaded the game, its next task is to start it. For this, it requires a few informations found in the [[Game_files|version manifest]].  
+
Once the launcher has authenticated the user and downloaded the game, its next task is to start it. For this, it requires some information found in the [[Game_files|version manifest]].
  
 
== Java version ==
 
== Java version ==
  
Until the Electron-based launcher, Minecraft stayed on the version of Java that had the most userbase, jumping from Java 6 in the early days, to Java 7 then 8.
+
Until the Electron-based launcher, Minecraft stayed on the version of Java that had the most userbase, jumping from Java 6 in the early days to Java 7, then 8.
  
Once the electron-based launcher, the version manifest embedded a javaVersion key that let it downloads the correct JVM for any given Minecraft version. This has the advantages that it does not expects anything about the user's computer (Even if the player does not have Java installed, the game will run).
+
Once the Electron-based launcher released, the version manifest embedded a <code>javaVersion</code> key that let it downloads the correct JVM for any given Minecraft version. This has the advantage of not expecting anything about the user's computer. The game will run even if the player does not have Java installed.
  
This JVM is downloaded to <code>$MINECRAFT_FOLDER/runtime/[javaVersion.component]/[OS]</code>
+
The JVM is downloaded to <code>$MINECRAFT_FOLDER/runtime/[javaVersion.component]/[OS]</code>
  
 
== Assets ==
 
== Assets ==
Line 20: Line 20:
 
On newer releases you can find them in the manifest under the <code>arguments.jvm</code> and <code>arguments.game</code> keys. Those are array of either a string corresponding to the argument or an object containing the <code>value</code> and the <code>rules</code> to check before appending the given argument. In case of an object, the <code>value</code> key can be either a string or an array of string.
 
On newer releases you can find them in the manifest under the <code>arguments.jvm</code> and <code>arguments.game</code> keys. Those are array of either a string corresponding to the argument or an object containing the <code>value</code> and the <code>rules</code> to check before appending the given argument. In case of an object, the <code>value</code> key can be either a string or an array of string.
  
The first version using this key is 1.12.2. For those before this one, you can check the <code>minecraftArguments</code> key. It's a string referencing all the arguments passed to the game. With the exception of the log4j config, no JVM arguments are passed to the game.
+
The first version using this key is 1.12.2. For those before this one, you can check the <code>minecraftArguments</code> key. It's a string referencing all the arguments passed to the game. With the exception of the log4j config, no JVM arguments are passed to the game so you must add the classpath and natives by yourself.
  
 
Here's a list of them with their corresponding description:
 
Here's a list of them with their corresponding description:
Line 36: Line 36:
 
| Load the natives
 
| Load the natives
 
|-
 
|-
| -Dminecraft.launcher.brand=${launcher_name}: 309
+
| -Dminecraft.launcher.brand=${launcher_name}
 
| The launcher name
 
| The launcher name
| @TODO: find out<sup>Need to dig deeper</sup>
+
| @TODO: find out
 
|-
 
|-
| -Dminecraft.launcher.version=${launcher_version}: 309
+
| -Dminecraft.launcher.version=${launcher_version}
 
| The launcher version
 
| The launcher version
| @TODO: find out<sup>Need to dig deeper</sup>
+
| @TODO: find out
 
|-
 
|-
 
| -cp ${classpath}
 
| -cp ${classpath}
| List of all the absolute path for the jars to load (libraries + client.jar) separated by <code>:</code>
+
| List of all the absolute path for the jars to load (libraries + client.jar) separated by <code>;</code> (on windows), <code>:</code> (on linux)
 
|
 
|
 
|-
 
|-
 
| -Dos.name=Windows 10 -Dos.version=10.0
 
| -Dos.name=Windows 10 -Dos.version=10.0
 
| Rule to be added only on Windows 10
 
| Rule to be added only on Windows 10
| @TODO: find out<sup>Need to dig deeper</sup>
+
| @TODO: find out
 
|-
 
|-
 
| -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
 
| -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
| Apparently used to make the game run smoothly on Intel Graphics. No real information on this<sup>Need to dig deeper</sup>
+
| According to [https://www.reddit.com/r/feedthebeast/comments/d8j90e/comment/f1b2anr/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button this] post, it forces laptops with Nvidia Optimus to use the GPU instead of iGPU.
 
|-
 
|-
 
| -XstartOnFirstThread
 
| -XstartOnFirstThread
Line 72: Line 72:
 
|-
 
|-
 
| --clientId ${clientid}
 
| --clientId ${clientid}
| @TODO: find out<sup>Need to dig deeper</sup>
+
| base64 encoded uuid from clientId.txt in .minecraft. Launcher seems to generate a new uuid on every install if the file is not present. (might be a random uuid every install?) @TODO: find out more
| @TODO: find out<sup>Need to dig deeper</sup>
+
| Optional, send in Telemetry
 
|-
 
|-
 
| --xuid ${auth_xuid}
 
| --xuid ${auth_xuid}
| @TODO: find out<sup>Need to dig deeper</sup>
+
| signerId in the JWT payload returned by the api.minecraftservices.com/entitlements/mcstore endpoint
| @TODO: find out<sup>Need to dig deeper</sup>
+
| Optional, send in Telemetry
 
|-
 
|-
 
| --username ${auth_player_name}
 
| --username ${auth_player_name}
Line 85: Line 85:
 
| --version ${version_name}
 
| --version ${version_name}
 
| Sets the version name of the game
 
| Sets the version name of the game
| @TODO: find out<sup>Need to dig deeper</sup>
+
| Used in the F3 debug screen and crash reports
 
|-
 
|-
 
| --gameDir ${game_directory}
 
| --gameDir ${game_directory}
Line 101: Line 101:
 
| --uuid ${auth_uuid}
 
| --uuid ${auth_uuid}
 
| The player UUID
 
| The player UUID
| @TODO: find out<sup>Need to dig deeper</sup>
+
| @TODO: find out
 
|-
 
|-
 
| --accessToken ${auth_access_token}
 
| --accessToken ${auth_access_token}
Line 108: Line 108:
 
|-
 
|-
 
| --userType ${user_type}
 
| --userType ${user_type}
| @TODO: find out<sup>Need to dig deeper</sup>
+
| The authentication scheme to use for logging in
| @TODO: find out<sup>Need to dig deeper</sup>
+
| <code>msa</code> for [[Microsoft Authentication Scheme]], <code>legacy</code> for [[Legacy Minecraft Authentication]] and <code>mojang</code> for [[Legacy_Mojang_Authentication]].
 
|-
 
|-
 
| --versionType ${version_type}
 
| --versionType ${version_type}
| Not sure, some launcher sets it to "release" / "snapshot" (MultiMC), other sets it as their [https://github.com/SKCraft/Launcher/blob/f45033e4fa81534a75c2802ec1116afe7f6df8cd/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java#L440 brand name] (SKCraft)
+
| [https://github.com/SKCraft/Launcher/issues/507 Only used to display on the main menu] and the F3 debug screen, some launcher sets it to "release" / "snapshot" (MultiMC), other sets it as their [https://github.com/SKCraft/Launcher/blob/f45033e4fa81534a75c2802ec1116afe7f6df8cd/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java#L440 brand name] (SKCraft)
 
|-
 
|-
 
| --demo
 
| --demo
| Not sure if it's still available
+
| Run the game in demo-mode
| Run the game in demo-mode (When the account does not own the game)
+
| Run the game in demo-mode
 
|-
 
|-
 
| --width ${resolution_width}
 
| --width ${resolution_width}
| Rule adding it only for "feature: has_custom_resolution"<sup>Need to dig deeper</sup>
+
| Rule adding it only for "feature: has_custom_resolution"
 
| Sets the game's width
 
| Sets the game's width
 
|-
 
|-
 
| --height ${resolution_height}
 
| --height ${resolution_height}
| Rule adding it only for "feature: has_custom_resolution"<sup>Need to dig deeper</sup>
+
| Rule adding it only for "feature: has_custom_resolution"
 
| Sets the game's height
 
| Sets the game's height
 +
|-
 +
| --disableMultiplayer
 +
| Disable Multiplayer button
 +
| Disable Multiplayer button
 +
|-
 +
| --disableChat
 +
| Disable receiving and sending online chat
 +
| Disable receiving and sending online chat
 +
|-
 +
| --quickPlayPath ${quickPlayPath}
 +
| Path (relative to the game directory) to a file to write quick play logs to
 +
| Optional, Sets the quick play log file
 +
|-
 +
| --quickPlaySingleplayer ${quickPlaySingleplayer}
 +
| Name or a world directory in the saves directory
 +
| Optional, Sets the world to load into after the game has started
 +
|-
 +
| --quickPlayMultiplayer ${quickPlayMultiplayer}
 +
| IP Adress of a server
 +
| Optional, Sets the server to load into after the game has started
 +
|-
 +
| --quickPlayRealms ${quickPlayRealms}
 +
| @TODO: how are realms identified
 +
| Optional, Sets the realm to load into after the game has started
 
|}
 
|}
  
Line 139: Line 163:
 
|-
 
|-
 
| --session ${auth_session}
 
| --session ${auth_session}
| No longer used ? Need to check how was implemented the newer auth in older versions
+
| Combined authentication argument: <code>token:${auth_access_token}:${auth_uuid}</code><sup>Need to check which versions used this</sup>
 
| The session ID used to authenticate with Mojang while connecting to servers
 
| The session ID used to authenticate with Mojang while connecting to servers
 
|-
 
|-
 
| --userProperties ${user_properties}
 
| --userProperties ${user_properties}
|  @TODO: find out<sup>Need to dig deeper</sup>
+
|  @TODO: find out
|  @TODO: find out<sup>Need to dig deeper</sup>
+
|  @TODO: find out
 
|-
 
|-
 
| --workDir ${game_directory}
 
| --workDir ${game_directory}
Line 192: Line 216:
 
| --assetsDir ${game_assets}
 
| --assetsDir ${game_assets}
 
| Used until 13w48b (Last release = 1.7.2)
 
| Used until 13w48b (Last release = 1.7.2)
| Probably the <code>/assets/virtual/legacy</code> for pre-1.6 assets<sup>Need to check</sup>
+
| Probably the <code>/assets/virtual/legacy</code> for pre-1.6 assets
 +
|-
 +
| --server ${server_ip}
 +
| Joins the server when the game is loaded
 +
| Join the server
 
|}
 
|}
  
Line 201: Line 229:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-  
 
|-  
! Classname
+
! Class Name
 +
! Applet Class Name
 
! Description
 
! Description
 
|-
 
|-
 
| net.minecraft.client.main.Main
 
| net.minecraft.client.main.Main
| Used by most versions
+
|
 +
| Used by most versions, all versions after 1.5.2, additionally including 13w16b.
 
|-
 
|-
 
| net.minecraft.launchwrapper.Launch
 
| net.minecraft.launchwrapper.Launch
| Used until 1.5.2, except 13w16b that for some reasons uses net.minecraft.client.main.Main
+
|
 +
| Used until 1.5.2, excluding 13w16b
 +
|-
 +
| net.minecraft.client.Minecraft
 +
| net.minecraft.client.MinecraftApplet
 +
|
 +
|-
 +
| com.mojang.minecraft.Minecraft
 +
| com.mojang.minecraft.MinecraftApplet
 +
|
 
|-
 
|-
 
| com.mojang.minecraft.RubyDung
 
| com.mojang.minecraft.RubyDung
| Used for really early versions
+
|
 +
| Used for really early versions.
 
|-
 
|-
 
| com.mojang.rubydung.RubyDung
 
| com.mojang.rubydung.RubyDung
| Used for really early versions
+
|
 +
| Used for really early versions.
 
|}
 
|}
 +
 +
NOTE: In early versions, the non-applet main class was obfuscated. For these versions, you can refer to the [https://github.com/PrismLauncher/meta/blob/main/meta/common/mojang-minecraft-legacy-override.json Prism Launcher meta repository].
  
 
It can be something else for custom instances, e.g. Forge instances.
 
It can be something else for custom instances, e.g. Forge instances.
Line 227: Line 270:
 
</code>
 
</code>
  
A frame with the game will popup and the logs will be available on standard output as expected
+
A frame with the game will popup, and the logs will be available on standard output as expected.
 +
 
 +
[[Category:Minecraft Modern]]

Latest revision as of 17:49, 14 September 2024

Once the launcher has authenticated the user and downloaded the game, its next task is to start it. For this, it requires some information found in the version manifest.

Java version

Until the Electron-based launcher, Minecraft stayed on the version of Java that had the most userbase, jumping from Java 6 in the early days to Java 7, then 8.

Once the Electron-based launcher released, the version manifest embedded a javaVersion key that let it downloads the correct JVM for any given Minecraft version. This has the advantage of not expecting anything about the user's computer. The game will run even if the player does not have Java installed.

The JVM is downloaded to $MINECRAFT_FOLDER/runtime/[javaVersion.component]/[OS]

Assets

The assets are expected to be downloaded according to the Assets section of the game files page, but also expects an $MINECRAFT_FOLDER/assets/indexes folder containing the JSON of the assets indexes available in the version manifest.

Arguments

Warning.png This section is a WIP as not all arguments explanation are available. If you know about them please contribute!

Running Minecraft requires several arguments.

On newer releases you can find them in the manifest under the arguments.jvm and arguments.game keys. Those are array of either a string corresponding to the argument or an object containing the value and the rules to check before appending the given argument. In case of an object, the value key can be either a string or an array of string.

The first version using this key is 1.12.2. For those before this one, you can check the minecraftArguments key. It's a string referencing all the arguments passed to the game. With the exception of the log4j config, no JVM arguments are passed to the game so you must add the classpath and natives by yourself.

Here's a list of them with their corresponding description:

JVM Arguments

Argument Description Usage
-Djava.library.path=${natives_directory} The natives folder path Load the natives
-Dminecraft.launcher.brand=${launcher_name} The launcher name @TODO: find out
-Dminecraft.launcher.version=${launcher_version} The launcher version @TODO: find out
-cp ${classpath} List of all the absolute path for the jars to load (libraries + client.jar) separated by ; (on windows), : (on linux)
-Dos.name=Windows 10 -Dos.version=10.0 Rule to be added only on Windows 10 @TODO: find out
-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump According to this post, it forces laptops with Nvidia Optimus to use the GPU instead of iGPU.
-XstartOnFirstThread Rule to be added only on OSX Makes the JVM starts with thread 0, required on OSX
-Xss1M - Sets the JVM stack size to 1M

Game Arguments

Argument Description Usage
--clientId ${clientid} base64 encoded uuid from clientId.txt in .minecraft. Launcher seems to generate a new uuid on every install if the file is not present. (might be a random uuid every install?) @TODO: find out more Optional, send in Telemetry
--xuid ${auth_xuid} signerId in the JWT payload returned by the api.minecraftservices.com/entitlements/mcstore endpoint Optional, send in Telemetry
--username ${auth_player_name} Sets the player username Used when logging in offline-mode, @TODO: find out if its useful in online-mode
--version ${version_name} Sets the version name of the game Used in the F3 debug screen and crash reports
--gameDir ${game_directory} The instance directory The game will locate every runtime files there (e.g. options.txt, world saves, ...)
--assetsDir ${assets_root} Should contain {indexes/, objects/, virtual/} The asset directory used by the game
--assetsIndex ${assets_index_name} Should contain the asset indexes JSON file for any installed version Let the games locate the assets based on its internal name in the assets/objects
--uuid ${auth_uuid} The player UUID @TODO: find out
--accessToken ${auth_access_token} The Mojang Access Token or the final token in the Microsoft authentication scheme Authenticate with the game
--userType ${user_type} The authentication scheme to use for logging in msa for Microsoft Authentication Scheme, legacy for Legacy Minecraft Authentication and mojang for Legacy_Mojang_Authentication.
--versionType ${version_type} Only used to display on the main menu and the F3 debug screen, some launcher sets it to "release" / "snapshot" (MultiMC), other sets it as their brand name (SKCraft)
--demo Run the game in demo-mode Run the game in demo-mode
--width ${resolution_width} Rule adding it only for "feature: has_custom_resolution" Sets the game's width
--height ${resolution_height} Rule adding it only for "feature: has_custom_resolution" Sets the game's height
--disableMultiplayer Disable Multiplayer button Disable Multiplayer button
--disableChat Disable receiving and sending online chat Disable receiving and sending online chat
--quickPlayPath ${quickPlayPath} Path (relative to the game directory) to a file to write quick play logs to Optional, Sets the quick play log file
--quickPlaySingleplayer ${quickPlaySingleplayer} Name or a world directory in the saves directory Optional, Sets the world to load into after the game has started
--quickPlayMultiplayer ${quickPlayMultiplayer} IP Adress of a server Optional, Sets the server to load into after the game has started
--quickPlayRealms ${quickPlayRealms} @TODO: how are realms identified Optional, Sets the realm to load into after the game has started

Legacy Arguments

Argument Description Usage
--tweakClass net.minecraft.launchwrapper.AlphaVanillaTweaker The class comes from net.minecraft.launchwrapper library Wrap the starting applet into a frame and setups up the params correctly
--session ${auth_session} Combined authentication argument: token:${auth_access_token}:${auth_uuid}Need to check which versions used this The session ID used to authenticate with Mojang while connecting to servers
--userProperties ${user_properties} @TODO: find out @TODO: find out
--workDir ${game_directory} Only in a few versions between 13w16a and 13w23b (including release 1.5.2) Same as newer --gameDir
--gameDir ${game_directory} - Same as newer --gameDir
--versionType ${version_type} - Same as newer --versionType
--userType ${user_type} - Same as newer --userType
--assetIndex ${assets_index_name} - Same as newer --assetIndex
--version ${version_name} - Same as newer --version
--username ${auth_player_name} - Same as newer --username
--uuid ${uuid} - Same as newer --uuid
--accessToken ${accessToken} - Same as newer --accessToken
--assetIndex ${assets_index_name} - Same as newer --assetIndex
--assetsDir ${assets_root} - Same as newer --assetsDir
--assetsDir ${game_assets} Used until 13w48b (Last release = 1.7.2) Probably the /assets/virtual/legacy for pre-1.6 assets
--server ${server_ip} Joins the server when the game is loaded Join the server

Main class

The main class is also referenced in the version manifest.

Class Name Applet Class Name Description
net.minecraft.client.main.Main Used by most versions, all versions after 1.5.2, additionally including 13w16b.
net.minecraft.launchwrapper.Launch Used until 1.5.2, excluding 13w16b
net.minecraft.client.Minecraft net.minecraft.client.MinecraftApplet
com.mojang.minecraft.Minecraft com.mojang.minecraft.MinecraftApplet
com.mojang.minecraft.RubyDung Used for really early versions.
com.mojang.rubydung.RubyDung Used for really early versions.

NOTE: In early versions, the non-applet main class was obfuscated. For these versions, you can refer to the Prism Launcher meta repository.

It can be something else for custom instances, e.g. Forge instances.

Building the final command

Once we have everything ready we can build the final command to start the game.

%JAVA_PATH%/bin/java [JVM Args] [main_class] [Game / Legacy Args]

A frame with the game will popup, and the logs will be available on standard output as expected.