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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.