mort mort - 4 months ago 68
Java Question

Launch Minecraft from command line - usename and password as prefix

I'm trying to make a simple custom Minecraft launcher thing.

According to minecraft wiki's Launcher page:
http://www.minecraftwiki.net/wiki/Minecraft_launcher,
it should be possible to run the minecraft launcher using username and password as prefix from the command line, and go directly to the game instead of through the launcher.

I've tried various versions of

java -cp -u=username -p=password minecraft.jar net.minecraft.LauncherFrame
, and what it says is the old method:

java -cp minecraft.jar net.minecraft.LauncherFrame <username> <password>


The old method opens the minecraft launcher, just as if I double clicked the jar file. It does not go directly to the menu screen.

The new way, using password and username as prefix, just give me an error message saying the
prefix -u=username or -p=password don't exist
.

Any help on this? I'm really stuck :/

Answer

You can do this, you just need to circumvent the launcher.

In %appdata%\.minecraft\bin (or ~/.minecraft/bin on unixy systems), there is a minecraft.jar file. This is the actual game - the launcher runs this.

Invoke it like so:

java -Xms512m -Xmx1g -Djava.library.path=natives/ -cp "minecraft.jar;lwjgl.jar;lwjgl_util.jar" net.minecraft.client.Minecraft <username> <sessionID>

Set the working directory to .minecraft/bin.

To get the session ID, POST (request this page):

https://login.minecraft.net?user=<username>&password=<password>&version=13

You'll get a response like this:

1343825972000:deprecated:SirCmpwn:7ae9007b9909de05ea58e94199a33b30c310c69c:dba0c48e1c584963b9e93a038a66bb98

The fourth field is the session ID. More details here. Read those details, this answer is outdated

Here's an example of logging in to minecraft.net in C#, and an example of launching minecraft.jar.