Search in sources :

Example 1 with EnderDragonEmpoweredLightning

use of com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonEmpoweredLightning in project EliteMobs by MagmaGuy.

the class EliteExplosionEvent method visualExplosionEffect.

public void visualExplosionEffect(ElitePower elitePower) {
    VisualExplosionEffectType visualExplosionEffectType;
    if (elitePower == null)
        visualExplosionEffectType = VisualExplosionEffectType.NORMAL;
    else if (elitePower.getFileName().equals(new EnderDragonEmpoweredLightning().getFileName()))
        visualExplosionEffectType = VisualExplosionEffectType.ASCEND;
    else if (elitePower instanceof EnderDragonTornado) {
        visualExplosionEffectType = VisualExplosionEffectType.HIGH_POWER;
    } else
        visualExplosionEffectType = VisualExplosionEffectType.NORMAL;
    for (BlockState blockState : blockStates) {
        FallingBlock fallingBlock = blockState.getBlock().getWorld().spawnFallingBlock(blockState.getLocation().add(new Vector(0, 0.2, 0)), blockState.getBlockData());
        fallingBlock.setDropItem(false);
        fallingBlock.setHurtEntities(true);
        switch(visualExplosionEffectType) {
            case ASCEND:
                fallingBlock.setVelocity(fallingBlock.getLocation().clone().subtract(explosionSourceLocation).toVector().normalize().setY(1).normalize().multiply(ThreadLocalRandom.current().nextDouble()));
                fallingBlock.setGravity(false);
                fallingBlock.setGlowing(true);
                break;
            case HIGH_POWER:
                fallingBlock.setVelocity(fallingBlock.getLocation().clone().subtract(explosionSourceLocation).toVector().normalize().setY(2).multiply(0.9));
                break;
            case NORMAL:
            default:
                fallingBlock.setVelocity(fallingBlock.getLocation().clone().subtract(explosionSourceLocation).toVector().normalize().setY(1).multiply(0.5));
        }
        new BukkitRunnable() {

            @Override
            public void run() {
                if (fallingBlock.isValid())
                    fallingBlock.remove();
            }
        }.runTaskLater(MetadataHandler.PLUGIN, 20 * 4);
        CrashFix.persistentTracker(fallingBlock);
        fallingBlocks.add(fallingBlock);
    }
}
Also used : FallingBlock(org.bukkit.entity.FallingBlock) EnderDragonTornado(com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonTornado) BlockState(org.bukkit.block.BlockState) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) EnderDragonEmpoweredLightning(com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonEmpoweredLightning) Vector(org.bukkit.util.Vector)

Aggregations

EnderDragonEmpoweredLightning (com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonEmpoweredLightning)1 EnderDragonTornado (com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonTornado)1 BlockState (org.bukkit.block.BlockState)1 FallingBlock (org.bukkit.entity.FallingBlock)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1 Vector (org.bukkit.util.Vector)1