Maximum PC

Minecraft Pi: Build a World

-

YOU’LL NEED THIS

RASPBERRY PI This tutorial works on any model of Raspberry Pi.

MINECRAFT: PI EDITION Comes bundled with Raspbian, and includes a Python API.

BESIDES EMPOWERING A NEW GENERATION OF MAKERS, the Raspberry Pi has also establishe­d its merits as a gaming platform. Projects such as RetroPie, combined with the Pi’s cheapness, mean that it’s great for playing old classics. And even some new ones. Such as Minecraft.

In case you’ve been living under a rock since 2011, Minecraft is the best-selling computer game of all time. It’s an open-world, sandbox affair, in which our hero, Steve, roams around a landscape made of voxels (blocks). Resources can be mined and crafted into other resources, so that Steve can build houses, farm crops, cook food, and fight enemies (all rendered in low-res splendor).

A special version, Minecraft:PiEdition, was released in 2013, and has been bundled with Raspbian since 2014. This version is in some ways cut down, in the sense that there isn’t any crafting or baddies, and nor is there any limit on the available resources. But it does have some features that aren’t present in the full game, most notably a Python API for manipulati­ng the world while a game is being played. Not having to worry about creatures trying to kill you or where your next meal is coming from makes it great for younger players, emphasizin­g the creative aspects of the game, and the Python API makes it an ideal platform for aspiring coders, young and old. –JONNI BIDWELL

1 FIRST STEPS To get started, head to the menu, then “Games > Minecraft Pi.” Choose “Single Player,” then “New Game.” The game window is offset from the app window behind it—ensure your cursor is parallel with the top of the app window, and hold down to reposition it.

>> Click “Start Game,” followed by “Create New.” Your new world now loads. Feel free to explore and build. The controls for the game are pretty simple, and are shown in the table to the right.

>> You can use the mouse to look around you. It can also be used to select items from the inventory. By default, you’re holding a sword. Click blocks to destroy them. The sword can also be used to dig. If you select a block from your inventory, you can begin building. Use the right mouse button to place the block, or the left button to destroy it. With time, patience, and some coding to automate block placement, you can have your very own castle [ Image A].

2 CODING BLOCKS To start coding in Minecraft:PiEdition, press the Tab key while it’s running. Go to “Menu > Programing.” Click “Python 3.” Try to place the text boxes so they’re next to one another.

>> You can type commands here to change the in-game world. Over time, you can also write scripts to automate tasks for you—for example, a script that places a stone block wherever you walk. So, let’s reprogram the game to display a simple message. Type in the following commands, pressing Return after each one: from mcpi.minecraft import Minecraft mc = Minecraft.create() mc.postToChat(“Hello world, I’m playing Minecraft Pi!!!”)

>> Press Return to display your first in-game message. Next, look at the top-left of the MinecraftP­i screen. You can see your X, Y, and Z co-ordinates. This is an excellent way to work out your location, as well as place blocks precisely.

>> You can use Python to summon any number of blocks of various materials. First, let’s try placing a single gold block immediatel­y behind you. Type in the following command:

x,y, z = mc.player.getPos()

>> You need to run the above command each time you move, to give the game your updated co-ordinates. Press Return, then type:

mc.setBlock(x+1, y, z, 41)

>> The number “41” at the end of the last command represents the ID number for gold. Each block or item in the game has a unique ID. If you know the ID of a particular type of block, assign it a name to make it easier to remember. For example:

gold=41

>> Press Return, then run these commands to create a giant 10x10x10 cube of solid gold [ Image B]: x,y, z = mc.player.getPos() mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, gold)

>> This is just a small selection of commands that can be run on MinecraftP­i. It’s also possible to form complex shapes, teleport the player, and even drop blocks as you move around. For a complete list of commands that you can run in Minecraft: PiEdition, as well as the ID numbers for each type of block, head on over to www.stuffabout­code.com/p/minecraft-apireferen­ce.html. 3 AVOIDING THE MINEFIELDS As we’ve discussed, MinecraftP­i is very similar to the Pocket edition of Minecraft, which can be played on handheld devices such as Android phones and iPhones. It can’t interact with people using the official Minecraft client. According to reports on the Mojang website, it appears the client hasn’t been updated in a while, but if you simply want to make simple structures and learn to code, without the extra features of the full Minecraft client, it’s ideal.

>> Although we’ve seen it’s possible to get the full version of Minecraft1.8.9 running on a Raspberry Pi 3 (see the boxout, above), the method isn’t officially supported by Mojang. This means that you’re likely to see reduced performanc­e compared to a regular desktop machine, including glitches and crashes some of the time.

>> The experiment­al graphics driver that has to be enabled on the Raspberry Pi to use the full version of Minecraft stops the official MinecraftP i client from working, but you can disable it again by running

sudo raspi-config , and then rebooting the machine. >> Neither version of Minecraft plays particular­ly well if you’re accessing the Pi over VNC, so it’s best to play it directly.

>> If you wish to play the full version of Minecraft, you do need to purchase an account from Mojang (currently priced at $26.95). If you now have the Minecraft bug and want to take it further, read on for details of how to set up your own Minecraft server on the Pi, and build your own digital world block by block.

 ??  ??
 ??  ??

Newspapers in English

Newspapers from United States