Java Reference
In-Depth Information
5.
Create a double (floating-point) variable named “dayOnIo” and set it to
152853.5047 . That's how many seconds a day lasts on Jupiter's moon, Io. 3
6.
Create a string named myName and set it to your name.
7.
Display each of these values by sending a chat message to the player, using
me.chat( string msg ) . For example, to display your name, type this:
me.chat( "My name is " + myName);
State each message with a string (like "My name is " ) and the plus sign. Then
add your variable. Don't forget the semicolon at the end of each statement.
Finally, add lines to play a sound effect at your location, using the float values
you just declared:
Location loc = me.getLocation();
playSound(loc, SoundEffect.Type.GHAST_SCREAM, volume, pitch);
Save the file and then run the build.sh in the Simple directory. (Make sure to
stop your server if you've left it running; some operating systems will throw
errors if you try to install fresh jars while the server is still running.)
$ cd Desktop
$ cd Simple
$ ./build.sh
Compiling with javac...
Creating jar file...
Deploying jar to /Users/andy/Desktop/server/plugins...
Completed Successfully.
Stop and restart your server, then connect from the Minecraft client. Run
your new command, /simple , and marvel at the messages on your console (and
the sound effect!).
Once that works, try changing the values for volume and pitch . Crank volume
up to 1.0f for a terrifying scream. For pitch, try a very low value, like 0.1f for
more of a growl, and higher ( 10.0f ?) for a piercing shriek.
After you type the new value in the Java source code, don't forget to take
these steps:
1.
Save the file.
2.
Compile and install with ./build.sh .
3.
Stop and restart the server.
4.
Reconnect your Minecraft client.
5.
Type /simple in the client and enjoy the display and sound effect.
3.
Io is pretty cool. It has more than 400 active volcanoes. See http://en.wikipedia.org/wiki/Io_(moon) .
 
 
 
Search WWH ::




Custom Search