Java Reference
In-Depth Information
Figure 4— playerTeleports is a hash with Player keys and Stack values.
Now what do we mean by “or close to it”? Notice that we're using a helper
function named equalsIsh (declared at ). It's checking two locations to see if
the x- and z-coordinates are within the same block. By casting the floating-
point values to integer (using the (int) keyword), we're throwing out the
fractional part of the coordinate. We're interested only if you're in the same
block, not at a slightly different position within the same block.
Try This Yourself
For this exercise, you're going to create a brand-new plugin that uses a listener.
Create a plugin named FireBow . If you fire an arrow, we want to make it explode
in a huge, crater-making explosion when it hits something. To do this, listen
for a ProjectileHitHook and call world.makeExplosion . Use a large value for the power,
like 100.0f to make a really large crater. Don't forget to cancel the arrow event;
that way, there will be no arrow—only a boom.
Hint: You can get the arrow from the ProjectileHitHook event using event.
getProjectile() .
Search WWH ::

Custom Search