Learning to program with Minecraft

Lead Image © Kenny Kiernan and vician, 123RF.com

Raspberry Craft

No two ways about it: For knowledge to stick, the training must be entertaining. Fortunately, learning to program in Python has just become a lot more fun – now you can learn by playing Minecraft.

Minecraft [1], the "social lego" with zombies, skeletons, and creepers, has become a social phenomenon, earning a place in the Smithsonian's "Art of Videogames," a feature-length documentary [2], an article in The Guardian, and ports to nearly every modern personal computing platform in existence, including the Raspberry Pi.

Although you can run a Minecraft server from your Pi, hardware constraints won't allow you to play the full version directly on your Pi. However, a client version has been adapted to the Raspberry Pi, and that is the one I'll be using in this article.

Down the Shaft

The Pi version of Minecraft [3] is a bit limited, in that you can only use the Creative playing mode. This is similar to early versions of the game for mobile devices. In this mode, you have no mobs (animals, monsters, and non-player humans – a.k.a. "villagers"), and although you can dig, you can't pick up blocks (mine) or transform combinations of blocks into new objects (craft). Instead, in your inventory, you have an infinite number of the blocks and tools you need, and you use those to do your building.

To start, Creative mode might make the Pi version less fun, but it is offset by the fact that the creators have included a nice and simple API that allows you to program new features into the game using the Python programming language.

Mining In

To install Minecraft, download the package [4] into a directory of your choice and unzip it from a terminal with:

$ tar zxvf  minecraft-pi-0.1.1.tar.gz

Now you can visit the mcpi directory (cd mcpi) and start playing the game by typing:

$ ./minecraft-pi

When you run Minecraft, you can choose either Start Game or Join Game, if a game is running on a server (Figure 1). For simplicity's sake, I'll be running a single-player game on a local server (i.e., I'll choose Start Game).

Figure 1: The first run of Minecraft: Pi Edition.

Although I will not delve into everything you can do in Minecraft, it'll help if you have a basic knowledge of how to make your way around the world. Table 1 lists some of the ways to navigate, take action, or even build something!

Tabelle 1

Minecraft Controls





Move in the direction the character is facing


Sidestep left


Move backward


Sidestep right

Space bar

Jump; double tap to start/stop flying, hold to fly higher


Crouch; hold to fly lower


Open inventory (use w, a, s, and d keys to navigate)


Select inventory slot item to use


Show/hide menu


Release mouse without showing menu


Confirm menu selection





Look/turn around

Left-click (hold)

Hit block to remove it


Place block; hit block with sword

Mouse wheel

Select inventory slot item to use

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Using the Raspberry Pi as a Minecraft server

    Minecraft has millions of devoted fans worldwide, and players who organize a communal game with friends and acquaintances achieve an entirely new gaming experience. The Raspberry Pi is an excellent replacement for the Minecraft server.

  • Don't Use a Hammer

    When you first start building, you probably learn how to use one device and one programming language. Then comes the day you design a project that your toolset either can't solve or forces you to jump through too many hoops to get the outcome you desire. That's the day you start looking at new devices and languages to solve your problem. Having an arsenal of tools at your disposal makes solving problems easier.

  • Synchronizing with broadcasts

    This article draws inspiration from the popular Pokémon Go app to recreate a sprite hunting game in Scratch. The project explores synchronization and randomness as the player explores various backdrops in search of sprites.

  • Exploring the Kano Kit Pi pack and learning environment

    The Kano Kit learning platform puts the Pi in easy reach for even the youngest users.

  • Using graphical effects to distort a picture

    In this guessing game, graphic effects distort sprite costumes while the player tries to guess the animal shape. The game is creatively scored based on how much the shape is distorted.