Hardware Reference
In-Depth Information
❍
showMaker(x,z)
and
hideMaker(x,z)
: hese functions use a gold block to show
which cell the program has reached as it builds the maze. It's fun to watch from above,
and is useful while building and debugging the program.
❍
demolish(realx,realz)
: his knocks down a wall in the maze, and takes a real
coordinate in the Minecraft world as its parameters.
❍
testAllWalls(cellx, cellz)
: his checks whether the four walls on a cell are
intact. If all of them are, it returns
True
. Otherwise, it returns False. It uses the com-
mand
mc.getBlock(x, y, z)
, which tells you the
blockTypeId
at a particular
location. You use two equals signs, as usual, to test whether a block in a wall position is
the same as the
MAZE_MATERIAL
, which means that there's a wall there.
Add these function deinitions at the start of your program, after where you set up the
Minecraft module:
def realx(x):
return MAZE_X+(x*2)-1
def realz(z):
return MAZE_Z+(z*2)-1
def showMaker(x, z):
mc.setBlock(realx(x), GROUND+1, realz(z), 41) # 41=gold
def hideMaker(x, z):
mc.setBlock(realx(x), GROUND+1, realz(z), 0)
def demolish(realx, realz):
mc.setBlocks(realx, GROUND+1, realz, realx, ;
HEIGHT+GROUND, realz, 0)
def testAllWalls(cellx, cellz):
if mc.getBlock(realx(cellx)+1, GROUND+1, ;
realz(cellz))==MAZE_MATERIAL and mc.getBlock;
(realx(cellx)-1, GROUND+1, realz(cellz))==MAZE_MATERIAL ;
and mc.getBlock(realx(cellx), GROUND+1, realz(cellz)+1)== ;
MAZE_MATERIAL and mc.getBlock(realx(cellx), GROUND+1, ;
realz(cellz)-1)==MAZE_MATERIAL:
return True
else:
return False