Hardware Reference
In-Depth Information
Relative coordinates refer to a set of coordinates such that their position is
relative to some other point (or in Minecraft, your player). For example, pos.x,
pos.y+10, pos.z+3 is a location inside the Minecraft world 10 blocks above
and 3 blocks south of your player: in other words, the coordinates are relative to
the position of your player. As your player moves around the Minecraft world, the
relative coordinates change as well.
Absolute coordinates refer to a set of coordinates that uses numbers at a fixed
location to represent the location of a point (or in the case of Minecraft, a block).
The coordinates x=10, y=10, z=15 are an example of absolute coordinates.
Every time you use these coordinates you refer to a block at location 10, 10, 15
inside the Minecraft world, which is always the same location.
CHALLENGE
If you have already done Adventure 2, load and run your whereAmI.py program
and move to a location in the Minecraft world that has some free space. Jot
down the x, y and z coordinates where your player is standing. Modify your
block.py program to setBlock() at that absolute coordinate , and run the
program to see what it does. How do you think relative coordinates and abso-
lute coordinates might help in your programs?
Building More than.One Block
From this basic beginning, you can build anything! You can now extend your program
to build more than one block. When you are building with Minecraft blocks, the only
thing you need to remember is that you will need to use some simple maths to work
out the coordinates of each block that you want to create.
You are now going to extend your build.py program to create five more blocks in
front of your player, using one setBlock() for each block that you want to create.
The program you're about to write will create a structure that looks a bit like the dots
on a dice. To do this, work through the following steps.
1. Start by choosing File Save As from the editor menu and saving your program
as dice.py .
2. Now add these lines to the end of the program:
mc.setBlock(pos.x+3, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x+3, pos.y+4, pos.z, block.STONE.id)
mc.setBlock(pos.x+3, pos.y, pos.z+4, block.STONE.id)
mc.setBlock(pos.x+3, pos.y+2, pos.z+4, block.STONE.id)
mc.setBlock(pos.x+3, pos.y+4, pos.z+4, block.STONE.id)
 
Search WWH ::




Custom Search