BUILDING THINGS IN Minecraft is great fun. You can build almost anything you can dream up, limited only by the size of the Minecraft world and your imagination. You can build houses, castles, underground waterways, multi-storey hotels with swimming pools, and even whole towns and cities! But it can take a lot of time and hard work to build complex objects with many different types of blocks, especially if there is a lot of repetition. What if you could automate some of your building tasks? Wouldn’t that look like magic to your friends?

A programming language like Python is ideal for automating complex tasks. In this adventure, you learn some magic that allows you to automatically build large numbers of blocks inside the Minecraft world and then loop through those instructions to build huge repeating structures, such as a whole street of houses (see Figure 3-1). Your friends will be amazed at your huge creations as they walk through rows and rows of houses and wonder how you built such complex structures! You also learn how to read numbers from the keyboard when your program first runs, which enables you to write programs that your users can vary without changing your program code!


FIGURE 3-1 A house built from Minecraft blocks

Creating Blocks

Each type of block in the Minecraft ...

Get Adventures in Minecraft, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.