Adventures in Python programming in Minecraft: the first steps

pythonminecraftprogIt’s surprisingly easy to get set up to program in Minecraft with Python on a PC or Mac.

I wrote yesterday about the excellent Thinkspace course that used a cut-down version of Minecraft on the Raspberry Pi to help teach kids about Python. It worked well but there were limitations. The chief limitation from my point of view was the Raspberry Pi. Not only did the Pi crash a bit too often for my taste, but I don’t need a Pi when we’re already swimming in Macs and PCs in our house. So I did some digging and found it’s possible to get the same broad set-up operating on a PC or Mac.

First, if you are interested in running this on the Raspberry Pi – you can find the instructions here.

On a Mac or PC, here’s what you need to do: First you need to download Craftbukkit server for Minecraft. Don’t use the latest build – go for 1.4.7 (download page is here). Instructions on setting up a server can be found in several places on the Internet. It’s not a complex task – the only fiddly thing is creating a small batch file to point to the version of Java that you have installed on your machine. The required text and information are all found on the Wiki.

We then downloaded Python version 2.6.6 – it does, for simplicity, have to be this older version; although I believe that with a little additional work you can run the latest version. Python comes nicely packaged with installers so it was a simple to put in place.

Next there is the Rapsberry juice plugin for the Bukkit server. After running and stopping the Bukkit server once, you put the plugin into the plugins folder and then start the server again. Note to newbies: If you don’t run the server once you wont find a plugins folder to put the plugin in. To check everything has worked just type “plugins” into the server console and you should see Raspberry Juice listed.

Finally we downloaded one more item: the API bridge and sample programs from mcpipy.

So after all that what did we end up with? We have Python installed on the computer. We have a single folder containing the bukkit server, the mcpipy API and sample programs. Any programs we create can then be saved to that sample folder too.

We can then run Minecraft client. On the loading screen we make a new profile and select 1.4.7 from the version drop-down menu. Using that profile we can connect to our Craftbukkit server using ‘localhost’ as the IP. Leave the server and client running while you write a program.

While there is some documentation on how to use the API with Minecraft, we found that looking at the sample programs was at least as helpful. In any case, the crucial thing to note is that you’ll need to start any program by importing the relevant modules (just copy and paste from the samples for simplicity). Once that’s done, you run your program and switch back to the Minecraft client to see the result.

Writing this down makes it seem like it might be complicated. In fact, doing it step-by-step, it wasn’t at all – the entire process was undertaken by my Senior Junior Technical Correspondent, Callum P, and took less than 30 minutes. There are some excellent references and resources available via the mcpipy website.

All the software, with the exception of Minecraft itself, is available for free. That is without doubt an advantage for the Pi in an educational environment: The Minecraft software is free. While the software itself is free on the Mac or PC, you can’t get it without an account which does cost. But then these days it’s becoming hard to find a kid who doesn’t have a Minecraft account.

What do we get for our efforts? We can basically use Minecraft as our console for Python programming. We can build with blocks and move characters around and we can communicate in both directions. I’m very excited by this in a teaching environment. Teaching kids about Python dictionaries, for example, seems like a dry undertaking when you output text to the console: But when you can use dictionaries to create sky-writing in Minecraft suddenly the whole thing comes to life. This approach wont systematically teach kids Python – but, if they are learning Python, using Minecraft like this gives the students a more visual, more engaging, way of seeing what they are coding.

My kids and I’ve spent the weekend playing with this and the possibilities, while not quite endless, are certainly very broad. One of the things I find fascinating is that you can get feedback from within Minecraft. That means it would be a small step to making a light come on when you do something in Minecraft – for example when you enter a room in Minecraft, a light comes on in your real room.

The major next step for us is to see if we can get most, or all, of this running from a USB key. It seems like it should be possible. Although the only reason to look at this is if you are working in a locked down environment such as the NSW Department of Education where installation can present problems.

I’d strongly recommend taking a look around the mcpipy website, before embarking upon this journey.

3 thoughts on “Adventures in Python programming in Minecraft: the first steps

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.