Learn to Program with Minecraft on Ubuntu

I've recently bought my 10-year-old daughter the book "Learn to Program with Minecraft". It seems to be a great book to start learning programming in Python, especially for kids who love playing with Minecraft.

Unfortunately there's a number of software packages to install, and the instructions are only available for Windows PCs, Apple Macs and the Raspberry Pi (which comes with everything pre-installed), and as my tri-boot iMac boots into Ubuntu Linux by default, I wanted to set them up on this OS.

Fortunately I found this excellent guide written by David G. Johnson, which explains step-to-step how to get started on Ubuntu. The bad news is, the instructions didn't work straight away for me, because the versions of the packages involved have moved on since he wrote that blog post, so I've spent a few extra hours to get it sorted.

I'll try to write down a summary of the instructions here, and then I will explain why as of today one can't simply follow David's guide as is.

# Install Java 8, Python 3 and friends
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install python3
sudo apt-get install idle3
sudo apt-get install python3-pip
sudo apt-get install git

# Compile the Spigot server, please note --rev 1.8.8
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
git config --global --unset core.autocrlf
java -jar BuildTools.jar --rev 1.8.8

# Configure the Spigot server in a few "simple" steps:
# 1) Start it, it will crash because you haven't accepted the EULA license:
java -Xms512M -Xmx1024M -jar ./spigot-1.8.8.jar
# 2) Edit file "eula.txt" just created in the current directory and replace "eula=false" with "eula=true"
# 3) Start again Spigot with the same command shown in 1), this time it will work. Type in "stop" at the prompt to make it exit again. This step is required to create the "server.properties" file and the "plugins" directories, which will be needed later on.
# 4) Edit the file "server.properties" to change "gamemode=0" to "gamemode=1", and "force-gamemode=false" to "force-gamemode=true" (this is to start in Creative Mode rather than Survival Mode, or your child will soon get upset).

# Download and install the Python Minecraft API
wget https://github.com/py3minepi/py3minepi/archive/master.zip
unzip master.zip && rm master.zip
sudo pip3 install ./py3minepi-master

# Download Raspberry Juice and put it in the "plugins"  folder of the Spigot server
wget http://dev.bukkit.org/media/files/875/204/raspberryjuice-1.7.jar
mv raspberryjuice-1.7.jar plugins

# Download Minecraft and make sure you have a paid-for account you can play with, for instance in Single-Player mode
wget https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar
java -jar Minecraft.jar

# Now you should be ready to go, without any automation script you would have to do the following every time:
# 1) Start the Spigot server and leave it running (one of the last few lines scrolling on the screen should mention Raspberry Juice):
# java -Xms512M -Xmx1024M -jar ./spigot-1.8.8.jar
# 2) From another terminal, start Minecraft:
# java -jar Minecraft.jar
# 3) In the Minecraft Launcher (the first screen you get when you start the program) select "Edit Profile" and then from the "Use version" drop-down menu select "release 1.8.8".
# 4) In Minecraft select "Multi-Player", then add a server, name it "Minecraft Python World", select host name "localhost", press "Done" and then click the play icon to join it.
# 5) Free the mouse pointer from Minecraft by pressing "Esc", then from a third terminal start IDLE, the Python Shell & Text Editor:
# idle3 &
# 6) Copy these commands in the IDLE Python Shell and verify that you don't get any error and your player gets teleported to the coordinates specified:

from mcpi.minecraft import Minecraft
mc = Minecraft.create()
mc.player.setTilePos(0, 120, 0)

# If everything works fine, you may want to create a script for your child to start Spigot, Minecraft and IDLE. This is a sample script:

#!/bin/bash -e
idle3 &
xterm -e 'java -Xms512M -Xmx1024M -jar ./spigot-1.8.8.jar' &
xterm -e 'java -jar Minecraft.jar' &

Unfortunately double-clicking the script didn't start it as expected, so I created a desktop icon named Minecraft.desktop with the following content:

[Desktop Entry]
Exec=bash -c '/absolute/path/to/previous/script.sh;$SHELL'

Ok, now as promised a brief explanation of what I've had to change compared to David G. Johnson's instructions.

If you build Spigot today, by default you get version 1.9; at the time of writing, there's no Raspberry Juice available for this server, the latest version being "Raspberry Juice 1.7 for Spigot / CraftBukkit 1.8.1".
As such, when building Spigot using my instructions, you have to override the default with option "--rev 1.8.8"; and when starting Minecraft you have to specify in the drop-down menu of the Minecraft Launcher that you want to use the same version, "release 1.8.8".
Apart from this, his instructions worked beautifully, so you may want to follow his guide. Thanks David!

About my daughter and the book, we've just started and I still don't know if she will get a grasp of Python anytime soon; but the whole kit costs around 35 GBP (half of which for the book and the other half for the Minecraft license), so it's not much; or maybe just the price of the book if you already have a PC/Mac/Linux license and/or own already or plan to buy a Raspberry Pi, which as I said comes with everything pre-installed.