Java Reference
In-Depth Information
You may not have all the answers yet. But that won't stop us; let's get started
(using my “creeper cow” idea).
What do you need to keep track of? We probably need to keep track of the
cows we spawn. We might need to keep track of players that each cow is tar-
geting and trying to attack, or maybe we'll figure that out for each cow as we
go along. We don't know which yet. Anything else? Oh, we want to randomly
create locations for the cows; do you remember what function to use to get
random numbers in Java?
How long do you need to keep it? Since these are randomly generated attack
cows, I don't think we need to keep track of them when the server shuts
down—we'll just make new ones. We will need to keep track of them in
memory while the server is running, though, so at a minimum we'll need
some kind of a static list or hash of the cows we've spawned. Reread Chapter
7, Use Piles of Variables: Arrays , on page 89 , or Chapter 11, Use Configuration
Files and Store Game Data , on page 145 , if you need a refresher.
What are the triggers? It would be kind of stupid to have to type in a command
to get attacked by creeper cows, so we won't be using a @Command function.
Instead, we'll need an event to kick off cow generation, and maybe a timer to
keep the cow attacking and make it eventually explode. We'll have to find
some kind of suitable event to listen for. Have a look back at Chapter 9,
Modify, Spawn, and Listen in Minecraft , on page 117 , and Chapter 10, Schedule
Tasks for Later , on page 135 , for details.
What parts of the game do you need to affect? We'll need to move the killer
cows around and blow them up, which we know how to do from the earlier
plugins. We'll need to blow up the player that we're attacking. Can we just
blow up when the cow is next to a player, or do we need to explicitly kill the
player (by setting health to zero or setting the player on fire or something)?
We'll need to experiment and see how that works.
What can go wrong? This is a question to ask yourself constantly when creating
a plugin. For now it seems likely our cows could get confused when attacking
and get stuck somewhere, or not have any player nearby to attack. So we'll
need to deal with that. Also, it's probably a good idea to limit the number of
cows we're going to spawn, so we don't accidentally create the Great Cow
It's not much, but it's a start. Here's what we've gathered so far:
•A static list or hash of cows we've spawned
•The Java function to make a random number (what was that again?)
Search WWH ::

Custom Search