Java Reference
In-Depth Information
Location objects are important—that's how you get and set the coordinates of
anything in Minecraft. Here's how we'll manipulate locations to fling the
creatures up in the air.
Use Minecraft Coordinates
A Location stores three coordinates: x, y, and z, as the following figure shows.
+high (255)
Sea level (64)
The x value goes west (negative) to east (positive), the z-coordinate goes north
(negative) to south (positive), and y goes down (negative) to up (positive), with
a y value of 0 being the bottom layer of bedrock and 64 being sea level. That
means that to make a player or other entity fly up in the air, you need to add
some to the y value.
We'll get each target's current y value from loc and save it as y . Next we'll
change the value in loc by adding 50. Here's the fun part: by calling target.tele-
portTo(loc) we tell the target to teleport itself to this new location.
Whew! That's a lot of stuff in a few lines of code. But give it a shot and compile
and install it using just like we've been doing:
$ cd Desktop
$ cd code/SkyCmd
$ ./
Stop and restart your server, and try out the new command /sky for fun. Make
sure you are in survival mode instead of creative mode, 1 and wait for night
to fall and the creepers to come.…
In the Minecraft game, you can do this by typing /gamemodec for creative or /gamemode
s for survival.
Search WWH ::

Custom Search