Please select an option to see content specific to your location and shop online.

Project

How To Dominate The World Of Minecraft With Pi

Scroll down

If there is a Minecraft god, he or she is a Pi hacker.

Everyone knows Minecraft. But not many people know that there’s a special version of the game for Pi. Why special? Because it’s one of the only version that lets you script the world – a programmable API enables you to write code and wield unimaginable power over your world. And we love that. Oh, and there are no monsters. Which, depending on your point of view, is okay too.

Here’s how to become a Minecraft god.

Setup

Download the game for free from pi.minecraft.net.

Unzip the downloaded file with: tar zxvf minecraft-pi-0.1.1.tar.gz

Start the game with: mcpi/minecraft-pi

Now you can play the game in the usual way – although this is a slimline variant of the main versions. But the exciting thing is that while you are playing you can open up a new LXTerminal window, and that’s when the real fun starts. Go get open it, you need to navigate to the folder containing the API module, then start a Python interactive session with: 8cd /home/pi/mcpi/api/python python

Game Play

The Minecraft module lets you connect with the world. Enter the following into the Python session:

>>> import minecraft

>>> mc = minecraft.Minecraft.create()

And you’re all set. You can now use the mc object to manipulate the world. You probably won’t find any official documentation anywhere but, as luck would have it, the code is commented. So have a poke about inside the minecraft.py file to uncover all the methods. Most of them simply revolve around getting a particular attribute or setting it. Here are couple to get you started:

Move the player to the coordinates 10,10,10:

>>> mc.player.setPos(10,10,10)

To set a particular block location to a specific block type, use:

>>> mc.setBlock(x,y,z,block_type)

(x,y and z are the coordinates, and block type is the numerical type ID – you’ll find a list of them at http://minecraft.gamepedia.com/Blocks, but not all of these are available in the Pi version).

So now you are the crowned leader of the world of Minecraft. Let us know what you create!

 

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.