Difference between revisions of "Launching the game"

From wiki.vg
Jump to navigation Jump to search
(Added and updated argument information based on my experiences creating a Minecraft launcher)
 
(3 intermediate revisions by one other user not shown)
Line 72: Line 72:
 
|-
 
|-
 
| --clientId ${clientid}
 
| --clientId ${clientid}
| @TODO: find out
+
| 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
+
| Optional, send in Telemetry
 
|-
 
|-
 
| --xuid ${auth_xuid}
 
| --xuid ${auth_xuid}
| @TODO: find out
+
| signerId in the JWT payload returned by the api.minecraftservices.com/entitlements/mcstore endpoint
| @TODO: find out
+
| 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
+
| Used in the F3 debug screen and crash reports
 
|-
 
|-
 
| --gameDir ${game_directory}
 
| --gameDir ${game_directory}
Line 112: Line 112:
 
|-
 
|-
 
| --versionType ${version_type}
 
| --versionType ${version_type}
| [https://github.com/SKCraft/Launcher/issues/507 Only used to display on the main menu], 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
|-
 
| --server ${server_ip}
 
| Joins the server when the game is loaded
 
| Join the server
 
 
|-
 
|-
 
| --width ${resolution_width}
 
| --width ${resolution_width}
Line 137: Line 133:
 
| Disable receiving and sending online chat
 
| Disable receiving and sending online chat
 
| 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 151: 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
 
|-
 
|-
Line 204: 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
 
|}
 
|}
  

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.