use of com.magmaguy.elitemobs.powers.majorpowers.enderdragon.EnderDragonTornado 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);
}
}
Aggregations