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)
(Add information, current info was contradictory to experience I just had with launching the game)
 
Line 57: Line 57:
 
| -XstartOnFirstThread
 
| -XstartOnFirstThread
 
| Rule to be added only on OSX
 
| Rule to be added only on OSX
| Makes the JVM starts with thread 0, required on OSX
+
| Makes the JVM starts with thread 0. Sometimes required on OS X but other times can cause the SWT thread to break and make the game stuck as "not responding" and not focusable.
 
|-
 
|-
 
| -Xss1M
 
| -Xss1M

Latest revision as of 07:49, 25 November 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. Sometimes required on OS X but other times can cause the SWT thread to break and make the game stuck as "not responding" and not focusable.
-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.