Hardware Reference
In-Depth Information
Quick Reference Table
Getting the block type at a position
Finding out which blocks have been hit
b = mc.getBlock(10, 5, 2)
hits = mc.events.pollBlockHits()
for hit in hits:
pos = hit.pos
print(pos.x)
Creating lists
Adding to the end of a list
a = [] # an empty list
a = [1,2,3] # an initialised list
a.append("hello")
Printing the contents of a list
Working out the size of a list
print(a)
print(len(a))
Accessing items in a list by their
index
Accessing the last item in a list
print(a[0]) # 0=first, 1=second
print(a[-1])
Removing the last item from a list
Looping through all items in a list
word = a.pop() # remove last item
print(word) # item just removed
for item in a:
print(item)
Further Adventures in
Interacting with.Blocks
In this adventure, you have learned how to use getBlock() to sense the block that
your player is standing on, and how to use events.pollBlockHits() to respond
when your player hits any face of any block. You've built a fantastic and complete game
within Minecraft, complete with scoring!
Set the RANGE constant to a larger number so that treasure is created further
away from your player. This will make your game more difficult to play, so try to
add a new feature that displays cold, warm or hot on the Minecraft chat depend-
ing on the distance your player is from the treasure.
Design a better scoring scheme to make it possible to get a reasonable positive
score as you play the game normally. Do lots of testing and work out what the
best score increment is for finding the treasure, and what the best score penalty
is for spending a gold block.
Research Pythagoras' theorem on the Internet, and see if you can code a better
distance estimator to make the homingBeacon() function more accurate.
(Psst! Martin covers a little bit about this in Adventure 7, so you could sneak a
peek at that adventure and see if you can work it out!)
 
Search WWH ::




Custom Search