Raspberry Pi – Minecraft

I don’t know about you, but for my Year 5s, Minecraft is a way of life – for the past 3 or 4 years I’ve seen it grow and grow in popularity to the extent that it’s no longer something cool to talk about, it is beyond cool, it’s just assumed that everyone knows what it is and plays it. So, when I first bought my Raspberry Pis, I remember enthusiastically telling the children that “you can use Minecraft on it”, which was greeted by some mumbling responses and one child declaring that it was too slow on the Pi.

When I went to Picademy I learnt the significance of Minecraft on the Pi – it’s not to play Minecraft, which can be done on any laptop, desktop, Xbox or even on Android & IOS devices, it’s to use lines of code to hack Minecraft and change the rules of the game.

The Minecraft section of our course was run by Craig Richardson, a former teacher with a passion for both Minecraft and the Raspberry Pi who is employed by the Raspberry Pi Foundation to pass on that enthusiasm to other teachers and children. He has very kindly shared his resources here and he even explains how to install Minecraft Pi Edition on your Raspberry Pi.

So, for those of you who don’t know, Minecraft is a simple, block based game where people can build, using blocks, houses and castles and boats and whatever their imagination requires. You can set up the game to be very simple i.e. resources are readily available, there are no bad guys etc or you can play so that you need to collect resources in order to make your buildings sustainable etc. It has never appealed to me in the slightest, but I really enjoyed using Craig’s hacks to explore the game and would consider looking at it again. One of the first things we were told when loading the Pi version of Minecraft is that the current version doesn’t work very well in full screen so don’t try to make your window full screen.

The first thing Craig asked us to do was to build a house. We discovered how to select different coloured blocks and built houses of varying quality (mine ended up being bright pink with a glass roof – it was hideous!). We also found out that to move our character (called Steve), we used the WASD keys, then the mouse clicks to play and select blocks. Once we’d built our houses, we were then asked to record the co ordinates of a point somewhere inside of it and then walk our character to another random point on the map.

In order to release the mouse from Minecraft, we had to press the tab key and then we could open Idle in order to type in some lines of code. Thankfully, Craig has helpfully created worksheets to go through all of this information including some extra tasks like creating a Minecraft folder in LXTerminal.

Screen Shot 2014-08-21 at 12.32.38 Screen Shot 2014-08-21 at 12.32.15

As with the CamJam sheets I looked at last week, I’m really impressed with the amount of detail in these workbooks – not only are the lines of code explained, there is some information on the back about what you’ve learned in terms of the language of code and an extension task. The first booklet explains everything from switching the Pi on to getting your code running and has a helpful big red box to remind you about using tab to release the mouse. From there you move on to making  flowers follow your character, then building a house in one go, using chat, freezing water and making a ‘block fighter’ mini game.

So let’s see how simple the instructions are to follow.

My first problem was that I couldn’t really remember how to control Steve in Minecraft so I had to sit for a while and press buttons until things happened – left click allowed you to smash things (either with your sword or without), right click allowed you to place blocks. Pressing E came up with a list of different materials that you can use to build. Pressing the space bar allowed you to jump and double pressing it allowed you to fly (double pressing a second time made you drop to the floor). I could also press ‘esc’ to alter the viewpoint from first person to third person (some of our group felt that the first person view made them feel a bit seasick). So I built myself a house…..

IMG_5556

In order to teleport into my house I need to make a note of the co ordinates of it – in the top left hand corner, in white, are the xyz co ordinates of my front door (which need to be rounded to the nearest whole number for the code to work). I actually want to teleport to the middle of the room so I’m going to use -30, 8 and -32 in IDLE an then save my code.

I hit upon a problem when I tried to run my code – I kept getting the error “no module named mcpi.minecraft” …a bit of fiddling and I discovered where I’d gone wrong – in my infinite wisdom, I’d saved my teleport file to completely the wrong place (I found a directory called .Minecraft and thought that sounded right), it turns out it’s important to save the file to the Documents folder called minecraft. So, now my code works I can move my character away from my house, tab out of Minecraft and then hit f5 in the Idle window and….tada, I’m back in my house!

Magic!

IMG_7774

I’ve mastered booklet 1, with one minor hiccup, so let’s take a look at number 2, the flower path – my goal is create a path of flowers that follow me around the map.

Screen Shot 2014-08-21 at 15.32.02

Maybe I’m just a bit more confident now, but this took me a few minutes to type in and, apart from accidentally missing the letter e off of Minecraft in one line of code, I had no problems….until I decided I wanted to get the flowers to stop following me, then I had a massive problem – luckily I’d written down that in order to stop the code you had to press ‘ctrl + c’ in the Python Shell window, otherwise I know I would have found myself getting really annoyed.

The extension task for this activity suggests changing the block variable value so that instead of flowers, you get melons, gold, water or even lava following you – I remember on our course we managed to make exploding dynamite follow us, which was highly amusing, albeit very destructive. Using this page I decided to try getting some different things to follow me – it did not like it when I tried to get Emeralds to follow me and I got a recurring ‘fail’ message across my screen and when I tried 319 for a ‘raw pork chop’ I ended up with a trail of wooden signs following me, so I guess it’s a bit of a case of trial and error (I did successfully manage to make running water appear under my feet using the codes).

Anyway, this is another fun Minecraft hack from Craig.

Just a final point – as I went to quit Minecraft, I suddenly got really upset that all my hard work building my house would go to waste, so I did a little research – by pressing escape I could quit the game, but the next time I loaded up Minecraft, instead of clicking on ‘create a new world’, I could click on my existing world and go back there -it seems that Minecraft Pi autosaves. While doing my research I learned that the version of Minecraft for the Raspberry Pi is a much more simple version compared to the full version so does not have the same scope for multiplayer etc, but it’s still good fun!

Personally, while Minecraft is a bit lost on me, I think that these 6 booklets are a fantastic way to get children interested in word based coding over block based because it’s not just typing in lines of code to make a message pop up, it’s typing in lines of code to ‘hack’ a game that they already play – it has huge mass appeal and I can’t wait to show the children I teach these booklets and let them have a go!

One thing I really appreciated about using IDLE over the LXTerminal is that it preempts the code you are typing and a little yellow box started hovering over my current line of code, suggesting what the rest of the line might need to look like. I also found that IDLE automatically put in line indents, which can be one of the reason lines of code fails.

So, if you teach children who are interested in Minecraft, I would thoroughly recommend taking a serious look at Craig’s worksheets and giving Minecraft hacking on your Raspberry Pi a go!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s