use of org.bukkit.entity.SpectralArrow in project EliteMobs by MagmaGuy.
the class ArrowFireworks method doArrowFireworks.
private static void doArrowFireworks(EliteEntity eliteEntity) {
Location centeredLocation = eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 3, 0));
for (int x = 0; x < eliteEntity.getDamagers().size(); x++) {
Location newLocation = centeredLocation.clone();
boolean validBlockFound = false;
for (int i = 0; i < 5; i++) {
Vector randomizedVector = new Vector(ThreadLocalRandom.current().nextInt(9) - 4, 0, ThreadLocalRandom.current().nextInt(9) - 4);
newLocation = centeredLocation.clone().add(randomizedVector);
if (NonSolidBlockTypes.isPassthrough(newLocation.getBlock().getType())) {
validBlockFound = true;
break;
}
}
if (!validBlockFound)
return;
SpectralArrow rocketArrow = (SpectralArrow) newLocation.getWorld().spawnEntity(newLocation, EntityType.SPECTRAL_ARROW);
rocketArrow.setShooter(eliteEntity.getLivingEntity());
rocketArrow.setVelocity(new Vector(0, 0.5, 0));
rocketArrow.setGravity(false);
rocketArrow.setGlowing(true);
new BukkitRunnable() {
int counter = 0;
@Override
public void run() {
if (!rocketArrow.isValid() || !eliteEntity.isValid()) {
cancel();
return;
}
if (counter < 20 * 1.5) {
rocketArrow.getWorld().spawnParticle(Particle.CRIT, rocketArrow.getLocation(), 1);
} else {
for (int i = 0; i < 30; i++) {
Arrow fireworkArrow = (Arrow) rocketArrow.getWorld().spawnEntity(rocketArrow.getLocation(), EntityType.ARROW);
Vector randomizedDirection = new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) * 2, (ThreadLocalRandom.current().nextDouble() - 0.5) * 2, (ThreadLocalRandom.current().nextDouble() - 0.5) * 2);
fireworkArrow.setVelocity(randomizedDirection);
fireworkArrow.setShooter(eliteEntity.getLivingEntity());
fireworkArrow.setGlowing(true);
}
rocketArrow.remove();
cancel();
}
counter++;
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
}
Aggregations