Updates to Minecraft Documentation – and a Python 3 version is on the way!

No … we’re not adding a Start Menu or a paperclip assistant. This update has nothing to do with Microsoft’s acquisition of Mojang. See the note below for information about this.

mcpi-game

You may remember when Mojang released Minecraft: Pi edition for free on Raspberry Pi back in early 2013. If you’re unfamiliar, Minecraft is a popular sandbox open world-building game (like on-screen lego) available for a number of different platforms like PCs, consoles and phones. The Pi edition has a Python programming interface allowing users to use code to build things and manipulate the virtual world around them. It’s a great way to learn coding, and there are plenty of great projects out there people have done and shared with the world.

mcpi-flying

Last week when we announced the release of the new Raspbian image, we mentioned that Minecraft is now installed by default. Now if you download NOOBS or the standalone Raspbian image, it will come with Minecraft pre-installed. It’s also worth mentioning that the Minecraft application is packaged, so rather than downloading the zip file you can easily install it like a standard application:

sudo apt-get update
sudo apt-get install minecraft-pi

The accompanying Python module will be installed globally along with the game itself you don’t need to save your Python scripts in a particular folder like you did before. If you’re following books, guides, tutorials or worksheets that were written before, the code will still work the same and if you install Minecraft the new way you’ll be able to save your scripts anywhere.

Once it’s installed, here’s the basic setup to get a “Hello world” in Minecraft:

from mcpi import minecraft

mc = minecraft.Minecraft.create()

mc.postToChat("Hello world")

mcpi-idle

When we launched the new Raspberry Pi website in April it came with a documentation section, which we’ve been expanding ever since. In May we announced the usage guides within this documentation were complete, which features basic how to guides for getting started with each of the main applications on Raspberry Pi.

We’ve just revamped the Minecraft section to explore more of the fundamental components of the Pi edition and its programming interface, including installation, running the game and Python side-by-side, exploring the programming interface and getting a good all-round introduction to what can be done.

You’ll also find this guide in our resources section, and for a full API reference see Martin O’Hanlon’s website stuffaboutcode.com

mcpi-tnt-explode

The edition we have at the moment was built for Python 2, and that’s still the case. However, the education team brought this up at PyConUK at the weekend and a team of developers offered to work on porting it to Python 3 – with some success!

IMG_20140922_114131.resized

The project is on GitHub and you can download the repository and use it the way you would use the old version of Minecraft (when you downloaded a zip) if you want to test it – just use IDLE 3 instead! We’re also planning to make some improvements to the API to make it more Pythonic and more intuitive. I’m not sure what the timescale will be for the port, but watch this space for news.

Python 3 is really important to us and we’re keen to make sure all libraries people use on the Pi are available in Python 3. Python 2 should not be the default, we should be pushing forward and adapting Python 3. As it says on the Python 2 or Python 3 page on python.org:

Short version: Python 2.x is legacy, Python 3.x is the present and future of the language
python.org

So if you’re the maintainer of a Python library, please help by making sure it’s available for Python 3. If you’re using a Python library that’s not available in Python 3 – please let us know so we can add it to the list and we’ll do what we can do get them ported.

One last note about the Microsoft acquisition of the Minecraft development company Mojang: many people have asked us what this means for the future of Minecraft on Raspberry Pi. In statements on their website, Microsoft claim they intend to continue to support Minecraft on all existing platforms. We don’t know for sure what the future will bring but Minecraft is important to us, particularly its use in education, and we’re confident that it won’t be taken from us.