Portable Minecraft

Started by Thorin, April 02, 2012, 10:53:20 AM

Previous topic - Next topic

Thorin

Over the weekend, I noticed in the Minecraft Launcher there's an Options button so I clicked it (wouldn't you?!).  The "options" are only a Force Update button and the location of the Minecraft files.  So I wanted to put all my Minecraft files (save data, downloaded mods, notes, etc) in one handy location, thinking that Minecraft would be able to store its data anywhere (otherwise why advertise where it's storing its data?).

Turns out Minecraft (on Windows anyway) always reads its data from %appdata%.  So on a typical computer, there's a C:\Users\[username]\AppData\Roaming\.minecraft folder.  Here's the easy workaround: make a batch file that sets %appdata% for the current process, then run Minecraft.exe.

So I copied %appdata%\.minecraft and created a batch file.

Here's my folder and file setup:

C:\Minecraft
C:\Minecraft\GameFiles
C:\Minecraft\GameFiles\.minecraft\*.*
C:\Minecraft\Mods
C:\Minecraft\Mods\JourneyMap1.5.2_MC1.2.4.zip
C:\Minecraft\Mods\ModLoader.zip
C:\Minecraft\Notes
C:\Minecraft\Minecraft Launcher.bat

I run Minecraft by running Minecraft Launcher.bat, the contents of which are:


@echo off
Title Starting Minecraft
echo Starting Minecraft...
echo.
echo ..Set AppData to %CD%\GameFiles
set APPDATA=%CD%\GameFiles\
echo.
echo ..Run Gamefiles\minecraft.exe
start GameFiles\minecraft.exe
echo.


This could conceivably run off a thumb drive or USB stick, as the whole structure is only 48MB and there does not appear to be any other dependency other than %appdata%.  All the save files are stored within %appdata%\.minecraft.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Lazybones

Handy for local creative mode stuff, but it is possible to play on the server with the browser version at http://www.minecraft.net/play

Mr. Analog

I had it on a Thumb Drive for a while doing this exact same thing.

I also had to write a BAT file to get it to work on Windows 7 64 bit (was getting massive client side problems that killed me several times with apparent "lag").
By Grabthar's Hammer

Thorin

I've read the browser version occasionally has problems?  Maybe that was for an older version.  Anyway, I was happy to see that all you need is a single folder of files and an internet connection to play this game.  No special folders that have to be at a specific place.  Well, %appdata%, but as stated that can be tricked into being somewhere else (without setting up a symbolic link, which is still kind of a pain in Windows).
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Melbosa

Quote from: Thorin on April 02, 2012, 11:24:47 AM
I've read the browser version occasionally has problems?  Maybe that was for an older version.  Anyway, I was happy to see that all you need is a single folder of files and an internet connection to play this game.  No special folders that have to be at a specific place.  Well, %appdata%, but as stated that can be tricked into being somewhere else (without setting up a symbolic link, which is still kind of a pain in Windows).
Well you also need Java support of some type as well.
Sometimes I Think Before I Type... Sometimes!

Mr. Analog

Well, yes, obviously :)

It's one of the requirements if I recall, I think the installer even checks which runtime you have to ensure compatibility.
By Grabthar's Hammer

Thorin

True, you need Java.  I guess that means it's not quite a play-anywhere, as Grandma's Computer might not have the newest JRE installed.  Of course, you could put the JRE installer on your thumb drive as well.  Dunno if that's useful for corporate computers, but I'm guessing that's less of a concern.

I wonder if there's a way to set the memory available to Minecraft?  I've had it crash a couple of times due to running out of memory when I've got the option set to see Far instead of Normal.  I've got 32-bit Windows, so 32-bit Java, and it's warned me that it could run out of memory due to it being 32-bit Java.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Melbosa

Quote from: Thorin on April 02, 2012, 12:11:33 PM
True, you need Java.  I guess that means it's not quite a play-anywhere, as Grandma's Computer might not have the newest JRE installed.  Of course, you could put the JRE installer on your thumb drive as well.  Dunno if that's useful for corporate computers, but I'm guessing that's less of a concern.

I wonder if there's a way to set the memory available to Minecraft?  I've had it crash a couple of times due to running out of memory when I've got the option set to see Far instead of Normal.  I've got 32-bit Windows, so 32-bit Java, and it's warned me that it could run out of memory due to it being 32-bit Java.

You can run the JRE with a Heap Size that limits the ram the JRE can use.

This is an example of my PMS (Playstation Media Server) launcher at home:
@echo off
REM -xmx###M is how much in MB the java engine can use in RAM
"C:\Program Files\Java\jre6\bin\javaw.exe" -classpath update.jar;pms.jar;plugins/;plugins/* -Xmx6144M -Djava.net.preferIPv4Stack=true -Djava.encoding=UTF-8 net.pms.PMS


PMS.jar is in the same dir as this code.
Sometimes I Think Before I Type... Sometimes!

Tom

Quote from: Thorin on April 02, 2012, 12:11:33 PM
True, you need Java.  I guess that means it's not quite a play-anywhere, as Grandma's Computer might not have the newest JRE installed.  Of course, you could put the JRE installer on your thumb drive as well.  Dunno if that's useful for corporate computers, but I'm guessing that's less of a concern.

I wonder if there's a way to set the memory available to Minecraft?  I've had it crash a couple of times due to running out of memory when I've got the option set to see Far instead of Normal.  I've got 32-bit Windows, so 32-bit Java, and it's warned me that it could run out of memory due to it being 32-bit Java.
If you run java directly, you can set the jre to use a specific amount of memory.

For instance, I have a little bash script to launch mc on my laptop:



#!/bin/bash

MINECRAFT_PATH=$HOME/.minecraft/bin
MINECRAFT_JAR=$MINECRAFT_PATH/Minecraft.jar
MEMALOC=512
JAVA_ARGS="-Djava.net.preferIPv4Stack=true -Xmx${MEMALOC}M -Xms${MEMALOC}M"

java $JAVA_ARGS -cp $MINECRAFT_JAR net.minecraft.LauncherFrame
-Xmx is max java heap size, and -Xms is initial java heap size. Note though that won't actually limit the entire memory use, as a bunch tends to get used indirectly through the C based libraries it uses to render and play music and what-have-you. Also GL/D3D tend to use up a lot of extra memory to cache textures. That memory limiting only effects the internal java heap (which is usually /most/ of the memory though).
<Zapata Prime> I smell Stanley... And he smells good!!!

Thorin

Yeah, but does that run the Minecraft Launcher that asks for your username/password?
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

Quote from: Thorin on April 02, 2012, 01:18:28 PM
Yeah, but does that run the Minecraft Launcher that asks for your username/password?

it should
By Grabthar's Hammer

Tom

Quote from: Thorin on April 02, 2012, 01:18:28 PM
Yeah, but does that run the Minecraft Launcher that asks for your username/password?
That Minecraft.jar file is the launcher. Which then looks into ~/.minecraft/bin/minecraft.jar for the actual game. Also notice the last part of the java command, "net.minecraft.LauncherFrame"  :)
<Zapata Prime> I smell Stanley... And he smells good!!!

Thorin

In Windows there's that Minecraft.exe that starts the whole she-bang.  Maybe it's calling the minecraft.jar with a memory setting?  Anyway, the warning and error messages both said it had to do with this being 32-bit Java instead of 64-bit Java.  Ima look up if those start with different default memory maxes.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

Quote from: Thorin on April 02, 2012, 02:28:15 PM
In Windows there's that Minecraft.exe that starts the whole she-bang.  Maybe it's calling the minecraft.jar with a memory setting?  Anyway, the warning and error messages both said it had to do with this being 32-bit Java instead of 64-bit Java.  Ima look up if those start with different default memory maxes.

As I mentioned before I can't use the exe because it causes really glitchy behaviour so I had to create a shortcut and call the jar directly.
By Grabthar's Hammer

Thorin

#14
Hmm, java says the class net.minecraft.LauncherFrame can't be found :(

edit: opened the jar file and cannot find LauncherFrame as a .class file in there anywhere.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful