8RUNNING AN AUTOMATED TREE FARM

image

In Chapter 6, we programmed a turtle to chop down a tree, but the player still has to manually place the turtle in front of a tree before the program can run. Placing a turtle in front of each tree you want to chop down isn’t much more efficient than harvesting a tree yourself. We can remove this manual step and fully automate the lumber-milling process by also programming the turtle to plant and grow saplings. As a result, the turtle can plant a sapling, harvest it when it becomes a tree, then plant a new sapling, and repeat the process without any human intervention! To do this, we’ll write a program called

Get Coding with Minecraft now with O’Reilly online learning.

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