Java Reference
In-Depth Information
For extra punch, I've added an effect on each block we traverse:
spawnParticle(b.getLocation(), Particle.Type.LAVASPARK);
The LAVASPARK gives us a nice set of sparks along our line of sight.
I've also added a sound effect, using the playSound helper function, which takes
a Location , and a Sound (and optionally floats for volume and pitch if you want).
playSound(b.getLocation(), SoundEffect.Type.EXPLODE);
There's a list of possible effects in the Canary documentation under
net.canarymod.api.world.effects.SoundEffect.Type . I picked EXPLODE for drama. (Option-
ally you can add the volume and pitch as two numbers after that; they are
specified to be float , not double , so remember to add the f modifier.)
Here's the full code, with the iterator and sound effect:
LavaVision/src/lavavision/LavaVision.java
package lavavision;
import net.canarymod.plugin.Plugin;
import net.canarymod.logger.Logman;
import net.canarymod.Canary;
import net.canarymod.commandsys.*;
import net.canarymod.chat.MessageReceiver;
import net.canarymod.api.entity.living.humanoid.Player;
import net.canarymod.api.world.effects.Particle;
import net.canarymod.api.world.effects.Particle.Type;
import net.canarymod.api.world.position.Location;
import net.canarymod.api.world.effects.SoundEffect;
import net.canarymod.api.world.blocks.Block;
import net.canarymod.api.world.blocks.BlockType;
import net.canarymod.BlockIterator;
import net.canarymod.LineTracer;
import com.pragprog.ahmine.ez.EZPlugin;
public class LavaVision extends EZPlugin {
@Command(aliases = { "lavavision" },
description = "Explode your target into a ball of flaming lava" ,
permissions = { "" },
toolTip = "/lavavision" )
public void lavavisionCommand(MessageReceiver caller, String[] args) {
if (caller instanceof Player) {
Player me = (Player)caller;
BlockIterator sightItr = new BlockIterator( new LineTracer(me), true);
while (sightItr.hasNext()) {
Block b = sightItr.next();
spawnParticle(b.getLocation(), Particle.Type.LAVASPARK);
 
 
 
Search WWH ::




Custom Search