Hardware Reference
In-Depth Information
Getting Started
Now that you've completed the Hello Minecraft World program in Adventure  1, it's
time for you to write your own program to link up with Minecraft!
Adventure  1 explained in detail how you get everything running and you'll perfect
those steps as you work your way through your adventures. All of the steps you need to
know to start everything up and begin typing programs are described in Adventure 1,
but we'll give you some reminders in the first few adventures while you're still learning
how to do it.
For a reminder on how to get Minecraft running properly on your particular
computer, visit the companion website at www.wiley.com/go/adventures
inminecraft and select the Adventure 1 video.
1. Start up Minecraft, IDLE, and if you are working on a PC or a Mac, start up the
server too. You should have had a bit of practice with starting everything up by
now, but refer back to Adventure 1 if you need any reminders.
2. Open IDLE, the Python Integrated Development Environment (IDE), just as you
did in Adventure 1. This will be your window into the Python programming lan-
guage, and it's where you will type and run all your Python programs.
Showing Your Player's Position
The best way to understand how coordinates work is to write a little experimental pro-
gram, so that's what you're going to do now. This program will show the 3D coordinates
of your player, and you'll be able to see the coordinates changing as your player moves.
1. From the Python Shell, create a new program by choosing File New File. A new
untitled window will open, which is where you will type your new program.
2. Before you start to type a program, it is good practice to save the file first, so that
if you have to rush away from your computer you don't have to think of a name
for the program under pressure. You just have to choose to save it. Professional
programmers do this all the time to make sure they don't lose their work. From
the Python Shell menu, choose File Save As, and type the name whereAmI.py .
Make sure that you save your program inside the MyAdventures folder.
3. Your program will be communicating directly with the Minecraft game through
the Minecraft API . To gain access to this API you will import the minecraft
module, which gives your Python program access to all the facilities of the
Minecraft game. Use the following to import the module:
import mcpi.minecraft as minecraft
 
Search WWH ::




Custom Search