How to get started with Minecraft on Raspberry Pi

Here's how to create your own custom Minecraft world on a Raspberry Pi.

How to get started with Minecraft on Raspberry Pi

1. Run Minecraft

During the extraction of the archive, a new folder was created, and it's called mcpi. We need to change our directory to mcpi so use the cd command again. Once done, use a command called ls to list the contents of the directory. Look for minecraft-pi – this is the Minecraft application.

How to get started with Minecraft on Raspberry Pi

2. Play around

To launch Minecraft, enter the following in a terminal: ./minecraft-pi. Have a play with Minecraft, create a new world and when it's ready, use the [W], [A], [S] and [D] keys to move around.

The mouse changes where you look, and the left mouse button destroys blocks, whereas the right one places a block.

How to get started with Minecraft on Raspberry Pi

3. Get the minecraft-api.py file

In Minecraft, to create objects, we must build them brick by brick. But if we use Python, we can make lots of things quickly.

We need to use the minecraft-api.py file and an application called IDLE. A link to IDLE can be found via the icon on the desktop.

How to get started with Minecraft on Raspberry Pi

4. Copy files

Make a directory called minecraft-api in your home directory and copy the contents of /home/pi/mcpi/api/python/mcpi (including any folders) to minecraft-api. The easiest way to do this is to use LXTerminal and type

cp -r /mcpi/api/python/mcpi /minecraft-api/minecraft

cp means to copy the files and the -r switch instructs the copy to include any sub directories. Also copy the downloaded tutorial file into this directory, ready for the next step.

How to get started with Minecraft on Raspberry Pi

5. Add a welcome message

Open the minecraft-api.py file in the IDLE editor and take a look at the code. First, let's change the code that says mc.postToChat ("Hello World") to say "Welcome to the game".

Save your work, start a new Minecraft session using any world, then in IDLE click on 'run' which is in the Run menu. You should see your text on the screen.

How to get started with Minecraft on Raspberry Pi

6. Drop in your player

Our player has a position, controlled via XYZ co-ordinates. We can check where our player is by using mc.player.getPos() and saving the output to a variable called playerPos, ready for use later.

Another idea is to use mc.player.SetTilePos(x,y,z) to drop your player into the game. We changed y to 50, and the player drops into the world.