Search in sources :

Example 1 with EntityExplodeEvent

use of org.bukkit.event.entity.EntityExplodeEvent in project Glowstone by GlowstoneMC.

the class Explosion method explodeWithEvent.

public boolean explodeWithEvent() {
    if (power < 0.1f)
        return true;
    Set<BlockVector> droppedBlocks = calculateBlocks();
    EntityExplodeEvent event = EventFactory.callEvent(new EntityExplodeEvent(source, location, toBlockList(droppedBlocks), yield));
    if (event.isCancelled())
        return false;
    yield = event.getYield();
    playOutSoundAndParticles();
    List<Block> blocks = toBlockList(droppedBlocks);
    for (Block block : blocks) {
        handleBlockExplosion((GlowBlock) block);
    }
    if (incendiary) {
        for (Block block : blocks) {
            setBlockOnFire((GlowBlock) block);
        }
    }
    Collection<GlowPlayer> affectedPlayers = damageEntities();
    for (GlowPlayer player : affectedPlayers) {
        playOutExplosion(player, droppedBlocks);
    }
    return true;
}
Also used : EntityExplodeEvent(org.bukkit.event.entity.EntityExplodeEvent) GlowPlayer(net.glowstone.entity.GlowPlayer) GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block) BlockVector(org.bukkit.util.BlockVector)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 Block (org.bukkit.block.Block)1 EntityExplodeEvent (org.bukkit.event.entity.EntityExplodeEvent)1 BlockVector (org.bukkit.util.BlockVector)1