Plugin: LavaVision

This plugin runs a BlockIterator for the player, and checks each block along the way, setting a flame effect. The first block that isn’t Air is the target, so we’ll set that to Lava.

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 ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.