Hardware Reference
In-Depth Information
FIGURE.8-2
The block friend is sad.
13.
The next section of code moves the block friend to his target:
if friend != target:
14.
Next, find all the blocks between the friend and his target by using the
get-
Line()
function in
MinecraftDrawing
:
blocksBetween = mcdrawing.getLine(
friend.x, friend.y, friend.z,
target.x, target.y, target.z)
he
getLine()
function works in the same way as
drawLine()
(see Adventure 7).
However, instead of drawing the line in blocks, it returns a list of points (x, y, z) that
make a line between the two sets of x, y, z co-ordinates passed as parameters.
15.
Directly under the previous code, you need to tell your program to loop through
all the blocks between the friend and the target, and move the block friend to
the next block between the block friend and the player:
for blockBetween in blocksBetween[:-1]:
mc.setBlock(friend.x, friend.y, friend.z, block.AIR.id)
friend = blockBetween.clone()
friend.y = mc.getHeight(friend.x, friend.z)
mc.setBlock(friend.x, friend.y, friend.z,
block.DIAMOND_BLOCK.id)
time.sleep(0.25)
target = friend.clone()