Hardware Reference
In-Depth Information
1. First, you need to find the position of the player by typing the following code:
pos = mc.player.getTilePos()
2. To draw a vertical line of 20 blocks from the player's position straight upwards,
type:
mcdrawing.drawLine(pos.x, pos.y, pos.z,
pos.x, pos.y + 20, pos.z,
block.WOOL.id, 1)
3. Now draw a horizontal line of 20 blocks straight across by typing:
mcdrawing.drawLine(pos.x, pos.y, pos.z,
pos.x + 20, pos.y, pos.z,
block.WOOL.id, 2)
4. Next draw a diagonal line of 20 blocks across and up:
mcdrawing.drawLine(pos.x, pos.y, pos.z,
pos.x + 20, pos.y + 20, pos.z,
block.WOOL.id, 3)
5. Finally, as we will be adding to this program, add a time delay so you can see
what is happening:
time.sleep(5)
6. Now save the file and run the program. You should have created three lines of
blocks, each in a different colour of wool: one running vertically from the play-
er's position, one running horizontally and the third running diagonally between
them.
DIGGING INTO THE CODE
The drawLine() function uses the Bresenham line algorithm to create the
line. Have a look at http://en.wikipedia.org/wiki/Bresenham's_line_algorithm to
learn more about the algorithm.
Drawing Circles
You don't have to stick to lines—you can also use MinecraftDrawing to create cir-
cles, by using the drawCircle() function, passing a centre point for the circle, a
radius and a block type. You can create a circle by using the function:
drawCircle(x, y, z, radius, blockType, blockData)
 
 
Search WWH ::




Custom Search