for (final Object shooter : shooters.getArray(e)) {
for (final EntityData<?> d : types.getArray(e)) {
if (shooter instanceof LivingEntity) {
final Vector vel = dir.getDirection(((LivingEntity) shooter).getLocation()).multiply(v.doubleValue());
if (Fireball.class.isAssignableFrom(d.getType())) {// fireballs explode in the shooter's face by default
final Fireball projectile = (Fireball) ((LivingEntity) shooter).getWorld().spawn(((LivingEntity) shooter).getEyeLocation().add(vel.clone().normalize().multiply(0.5)), d.getType());
ProjectileUtils.setShooter(projectile, shooter);
projectile.setVelocity(vel);
lastSpawned = projectile;
} else if (Projectile.class.isAssignableFrom(d.getType())) {
final Projectile projectile = ((LivingEntity) shooter).launchProjectile((Class<? extends Projectile>) d.getType());
set(projectile, d);
projectile.setVelocity(vel);
lastSpawned = projectile;
} else {
final Location loc = ((LivingEntity) shooter).getLocation();
loc.setY(loc.getY() + ((LivingEntity) shooter).getEyeHeight() / 2);
final Entity projectile = d.spawn(loc);
if (projectile != null)
projectile.setVelocity(vel);
lastSpawned = projectile;
}
} else {
final Vector vel = dir.getDirection((Location) shooter).multiply(v.doubleValue());
final Entity projectile = d.spawn((Location) shooter);
if (projectile != null)
projectile.setVelocity(vel);
lastSpawned = projectile;
}
}
}
}