Friday, 6 June 2014

Adding a Second Minecraft Server in Linux


We've been using the linux startup script from the minecraft wiki for some time now and generally it works a treat, but recently I've wanted to set up a second service for my two younger sons to play on, away from the highly modified worlds that my oldest son had set up. The script can't cope with two services running at the same time, but with a few tweaks you can run as many as you like. The following instructions create a new game server called Pinga using a service called kidcraft.

Creating the New Minecraft Installation

I wanted it use vanilla Minecraft version 1.5.2, which was the very first version that we tried, but it should work for any version including craftbukkit, or any other modded versions.

1. Make a copy of your existing Minecraft installation.

cp -Rv /opt/minecraft /opt/kidcraft

2. Remove the old world directories (in my case the world was called 'Plop')

rm -R Plop

3. Edit your file and change the following settings:-
   - server-port : 25566 (the default is 25565 so pick a number that isn't being used)
   -server-name : Pinga (enter your new server name)
   - level-name : Pinga (will be used to name your new world)
   - gamemode : 1 (Creative - my kids don't want to play survival, you can leave this as 0)

Also make sure the other settings are set back if altered from standard.

4. Empty the Ops, Banned-ip, Banned-players and White-list files or delete them (they'll get recreated when you start the server).

5. Start the server up and allow it to create a new world.

6. Check you can connect to it in the game using the Multiplayer option.

7. Close down the server.

Create a New Backup Folder

If you use the backup option then you want to specify a new location for the files so they don't get mixed in with your existing backups. Mine were going into the /DailyBackup/Minecraft folder.

8. Go to your backup folder and create a new sub-directory

cd /DailyBackup
mkdir kidcraft

Modifying the Startup Script

The startup script uses the 'screen' utility as the control mechanism, and this also allows you to access the console if required. You will need to make some changes to the new script so that the commands connect to the correct service.

 9. Copy the startup script

cp /etc/init.d/minecraft /etc/init.d/kidcraft

10. Ensure it can be executed

chmod 755 /etc/init.d/kidcraft

11. Edit the new startup script and modify the following:-
   - WORLD : 'Pinga'
   - MCPATH : '/opt/kidcraft'
   - BACKUPPATH : '/DailyBackup/kidcraft'

12. Then alter the startup line in the mc_start() function

as_user "cd $MCPATH && screen -h $HISTORY -dmS kidcraft $INVOCATION"

13. Repeat stage 12 for the following functions:-
   - mc_saveoff()
   - mc_saveon()
   - mc_stop()
   - mc_command()

14. Save and exit the file.

You should be able to start and stop the new service using this new script in the normal way.

eg. /etc/init.d/kidcraft start

You can also access the console using the following command.

screen -r -S kidcraft

(Nb. use Ctrl + A D to exit)

One more thing..

Nearly forgot,.. if you want to make this server available over the web, don't forget to set up another port forwarding service on your router.


An improved method can be found here

Tuesday, 3 June 2014

Minecraft 1.5.2 on Snow Leopard

The Trials of Old Kit

I've pretty much given up trying to get Minecraft running on my old PowerPC Mac Mini (and I don't think I'm alone in that), so I dug out my black Macbook from around 2009. My original problem had been that Apple and Oracle had given up on the PPC processor so OSX was stuck at Leopard and Java with Apples version of 1.5, so I assumed the Macbook with it's intel Core Duo CPU would be easy.

Seems I was wrong again!

Its all about the Java

After installing the Minecraft launcher I initially found it crashed after trying to start the game (just like before). I managed to find a Java update that had been recompiled to NOT stop when it found an old version of the OSX.

With this I was able to get Minecraft working, but only on version 1.6.1 or higher. But my server is 1.5.2 and upgrading wasn't an option. I have a friend who's kids play on an old PC that doesn't like any version later than this because of video driver issues.

Once again, after lots of googling I was unable to find a solution to the problem, it seems that the launcher was broken some time after v1.5.2 and thus later versions just won't work on Snow Leopard.

Shoot the Snow Leopard

I'd always held off upgrading to Lion because it meant losing Rosetta and I'd actually quite liked Snow Leopard. I saw it as a better, more 'sorted' version of Leopard, but as this laptop just wasn't being used anymore I didnt have anything to lose. The upgrade went smoothly and was followed by a 2Gb system update.

After this I started up Minecraft and it just worked (wow) albeit running slightly warm. I then spent a little time tinkering with the video settings in the game to get it running smoothly (turning on advanced OpenGL, setting the Graphics to 'Fancy' and turning off clouds). Everything was running great until I turned off full screen mode to see if it would run cooler. Then it crashed in disgust, refusing to restart.

It took a little trial and error to work out how to fix it, but here's all you need to do:-
  • Set your launcher to use the latest version of the game.
  • Launch the game and then go into the video settings.
  • Switch back to fullscreen mode
  • End the game
  • Switch back to 1.5.2 and relaunch.
Simple enough to fix. I suspect there's some sort of backwards incompatibility with the video drivers and earlier versions of Minecraft. In my experience the world of Java is full of version issues and gotchas. But this is the price you pay for cross platform compatibility.

For a simple looking blocky game it sure does make my laptop run hot.