Hardware Reference
In-Depth Information
he irst line imports the sys and random modules. he random module you'll need later to
build a random maze as you develop this program. Use the sys module straight away to tell
IDLE where it can ind the Minecraft Python module, which enables you to pass commands
to Minecraft to carry out. After telling IDLE where it is, you import the module.
To issue Python commands to Minecraft, you use minecraft.Minecraft.create()
and then add the command at the end. For example, to put a greeting in the chat window,
you might use the following:
minecraft.Minecraft.create().postToChat(“Welcome to ;
Minecraft Maze!”)
hat soon gets hard to read, so in the previous program, you set up mc so that you can use it
as an abbreviation for minecraft.Minecraft.create() . As a result, you can use the
shorter line that you see in the program to post a message.
If your code isn't working, pay particular attention to the case. Python is case sensitive, so
you have to use upper- and lowercase exactly as shown here. Look out for the camel case in
postToChat , and the capital M in minecraft.Minecraft.create() .
Understanding Coordinates in Minecraft
As you might expect, everything in the Minecraft world has a map coordinate. hree axes are
required to describe a position in the game world:
x: his axis runs parallel to the ground. he values run from -127.7 to 127.7.
y: his axis runs vertically and could be described as the height. You can ly at least as
high as 500, but you can't see the ground from higher than about 70, so there's not
much point. Sea level is 0. You can break blocks to tunnel under the sea too. I made it
down to about -70 before I fell out of the world and died. his is the only way I've seen
that you can die in Minecraft on the Pi.
z: his is the other axis parallel to the ground. he values run from -127.7 to 127.7.
I put them in that order deliberately because that's the order that Minecraft uses. If, like me,
you often use x and y to refer to positions in 2D, such as points on the screen, it takes a short
while to get your head around the fact that y represents height. Most of the time in this
chapter, you'll be using the x and z coordinates to describe a wall's position (which difers
depending on the wall), and the y coordinate to describe its height (which doesn't).
 
Search WWH ::




Custom Search