image

COMPUTERS DON’T THINK. They aren’t capable of having any thoughts at all; they can only ever do what programmers tell them to do. You can, however, make computers look like they are thinking and making decisions by themselves. By programming your computer to “understand” what’s happening and giving it rules to “decide” what to do next, you can open a door to a lot of fun.

In this adventure, you are going to program a block friend who will follow you around, provided you don’t get too far away. You are also going to create a flying saucer that chases you until it can get above you and beam you aboard.

You learn how to make a block move and follow the path it decides is best, as well as how to use the Python random module to make it look as if the computer is thinking. You also create shapes using the MinecraftShape functions in the minecraftstuff module (which is included in your starter kit).

Your Block Friend

Minecraft can be a lonely world. But your player doesn’t have to be alone—you can create a block that will follow him around, talk to him and be his friend (see Figure 7-1).

image

FIGURE 7-1 Create a block friend to accompany your player on his Minecraft adventures.

To program a block friend you need to think like her! She will be happy if she’s near your player, so she will ...

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.