Terraforming Minecraft

By Russell Barnes. Posted

Everyone has their favourite Minecraft block. What if you could have an entire world made out of them?

Imagine fields of gold, fit for King Midas or the dragon Smaug. Or how about a frozen landscape where everything has been turned to ice? Just think what you could do in a world where everything is primed TNT.

Using Python, we can start a terraforming process to remake a Minecraft world to your specifications. Even on a Pi 3, this will not be a quick process: depending on how complex your landscape is, and how much you want to transform, it may take several days. So we’ll monitor our progress by uploading data to an Initial State dashboard so that we can keep track of things remotely. If you just want to do the terraforming, there’s another version of the code without the Initial State functionality in the same GitHub repository (terraformingnois.py).

The full article can be found in Hacking and Making with Minecraft and was written by the Hayler-Goodalls. If you want more tutorials like this and a beginners guide to programming Minecraft Pi, check out the rest of the book

 Our latest Essentials book is full of Minecraft modding tips

You'll need

An Initial State account
ISStreamer and Python 3 library
psutil Python 3 library

STEP-01 Generate your world

Before you start coding, you need to create your Minecraft Pi Edition world and select the block type with which you want to fill your world. This can be any block of your choice, but it has to be a solid block (not ladders or torches). Manipulating the Minecraft ecosystem can be tricky. For example, if you try to turn water directly to lava, you’ll probably end up with lakes of obsidian, so you might need an intermediate step: turn all the water to something inert (like wool), then transform it to lava. There may also be some blocks you want to keep – snow or water, for example.

STEP-02 Get the code

Make sure your Pi is up to date and, if you want to create a remote monitoring dashboard on Initial State, download and install its data streaming library:

sudo pip3 install ISStreamer psutil

Then download the is_terraforming.py code. Note that you’ll need to change some of the values to suit your Minecraft environment and to include your Initial State account details.

STEP-03 Tune the code

Terraforming can take a long time – we’re talking days rather than minutes. However, we can tune our code to speed things up. Explore your world and find the tallest mountain range and deepest valley. Make a note of the height (the third value displayed in the top-left corner of the screen). You can then plug these values into the code.

We have set the default terraforming height range from -3 to 35 on the y axis, but you can make this bigger (this will take longer) or shorter (this will take less time), depending on the size of the geological features in your world.

 Don't throw stones in a world made of glass

STEP-04 Set the speed for the power of your Pi

This code should work on any type of Pi, but older, less powerful models may struggle if you terraform at full speed. If Minecraft can’t keep up with all the changes it’s being asked to make to the landscape, it may hang. Therefore, it’s a good idea to pause after a certain number of blocks, to allow Minecraft to catch up. On a Pi 3, you can comfortably transform 500+ blocks before the need for a pause, but for a Model B you may need to deal with 50 blocks at a time. You’ll probably want to run a few experiments to find the optimum configuration for your setup.

STEP-05 Register for an Initial State account

Initial State allows you to upload live data and plot interesting charts and graphs. A free account lets you stream 25,000 events a month and examine the last 24 hours’ worth of data in any bucket. Once you have registered for an account, click on the ‘create HTTPS bucket’ button (the plus symbol) and give it a suitable name. Then check ‘Configure Endpoint Keys’ and copy the Bucket Key and Access Key into your version of the code.

STEP-06 Start terraforming!

If you’re using a free account, edit the code and set the Free_account variable to True. This will throttle the amount of data sent to Initial State and allow you to record the whole process without exceeding the data cap.

Start your code running and check the console for any errors. You can fly to the corner of your world and should soon be able to see the changes taking place. Once the first data reaches Initial State, you can create a cool dashboard: use the Tiles interface and play around with the different types available.

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.