Hardware Reference
In-Depth Information
8. Ask your program to check to see if the position of the block the player just hit
with his sword is the same as the position of the diamond. If it is, ask it to post a
message to the Minecraft chat:
if pos.x == diamond_pos.x and pos.y == diamond_pos.y
and pos.z == diamond_pos.z:
mc.postToChat("HIT")
9. Finally, write your game loop. For now, you'll use a time delay of one second, to
limit how quickly messages can appear on the Minecraft chat, but you might like
to experiment with different time delays to get the best usability from your pro-
gram. Check your indentation very carefully here:
while True:
time.sleep(1)
checkHit()
Save your program with File Save As and run it using Run Run Module from the
editor window.
Move your player around a bit until you can see the diamond. Now, hit it on each of its
faces with a sword. What happens? As Figure 4-6 shows, when you hit the diamond,
the message “HIT” appears on the Minecraft chat.
FIGURE.4-6 A block has been hit.
Search WWH ::




Custom Search