The great thing about the Raspberry Pi Edition of Minecraft is that you can manipulate the game world using Python scripts. You can move the player as well as create and destroy blocks. This allows you to create structures in seconds that would take hours to create by hand.
By repeating a script you can quickly create structures you have designed. For example you could write a script to create a tower and a section of wall and use it to quickly create a massive castle.
To configure your Pi to allow this you need to follow a few initial steps. They are fairly straight-forward and only take five minutes.
2015 Update :
The latest version of Raspbian includes the installation of Minecraft and the Minecraft API. This mean you can skip Steps 1-3. Your Python scripts can be run from any directory. I strongly suggest you update your SD card with the latest Raspbian image if you don’t already have Minecraft or the API installed.
Step 1 – Install Minecraft
Please follow my Installing Minecraft on the Raspberry Pi tutorial and check the game works as expected.
Step 2 – Configure the API
The files required are now already installed but to make them a bit easier to access we are going to copy them into a new folder. So lets create it in the default home directory :
and then copy the files from Minecraft installation :
cp -r ~/mcpi/api/python/mcpi ~/mcpi-api/
Step 3 – Navigate To Folder
Before diving in with your own scripts it is best to test everything is working ok. Navigate to the API directory created earlier :
Step 4 – API Test
To test your setup you can use the following simple script. It creates a cube made of stone and places you on top of it.
#!/usr/bin/python # Import Minecraft libraries import mcpi.minecraft as minecraft import mcpi.block as block mc = minecraft.Minecraft.create() # Get player position pPos = mc.player.getTilePos() mc.postToChat("API Test!") # Change block print "Create stone 3x3 cube" mc.setBlocks(pPos.x-1,pPos.y,pPos.z-1,pPos.x+1,pPos.y+2,pPos.z+1,block.STONE) print "Position player on top" mc.player.setPos(pPos.x,pPos.y+3,pPos.z) mc.postToChat("Move and have another go.")
You can download this script directly to your Pi using :
It can be run using :
Make sure Minecraft is running before you try the test script or nothing will happen! Pressing TAB will free the mouse from the game window and let you use the LXTerminal.
When the script has run you should see a stone cube under your feet :
Minecraft Python API Block Names Reference
For reference the following Block names are available if you want to change the script above to create a cube made of a different material :
AIR STONE GRASS DIRT COBBLESTONE WOOD_PLANKS SAPLING BEDROCK WATER_FLOWING WATER WATER_STATIONARY LAVA_FLOWING LAVA LAVA_STATIONARY SAND GRAVEL GOLD_ORE IRON_ORE COAL_ORE WOOD LEAVES GLASS LAPIS_LAZULI_ORE LAPIS_LAZULI_BLOCK SANDSTONE BED COBWEB GRASS_TALL WOOL FLOWER_YELLOW FLOWER_CYAN MUSHROOM_BROWN MUSHROOM_RED GOLD_BLOCK IRON_BLOCK STONE_SLAB_DOUBLE STONE_SLAB BRICK_BLOCK TNT BOOKSHELF MOSS_STONE OBSIDIAN TORCH FIRE STAIRS_WOOD CHEST DIAMOND_ORE DIAMOND_BLOCK CRAFTING_TABLE FARMLAND FURNACE_INACTIVE FURNACE_ACTIVE DOOR_WOOD LADDER STAIRS_COBBLESTONE DOOR_IRON REDSTONE_ORE SNOW ICE SNOW_BLOCK CACTUS CLAY SUGAR_CANE FENCE GLOWSTONE_BLOCK BEDROCK_INVISIBLE STONE_BRICK GLASS_PANE MELON FENCE_GATE GLOWING_OBSIDIAN NETHER_REACTOR_CORE
You are now ready to create your own scripts! Exactly how complicated you make them is up to you.