public void shoot() {
Player shooter = manned ? getShootingPlayer() : null;
if(shooter != null) {
Arrow ar = area.getWorld().spawnArrow(BlockUtil.getBlockCentre(area.getCenter() == null ? area.getCenter().getBlock() : getBackBlock()).add(0, 1, 0), shooter.getLocation().getDirection().normalize(), speed, 0);
ar.setShooter(shooter);
ar.setTicksLived(2500);
} else {
for (Entity ent : area.getEntitiesInArea()) {
if(!(ent instanceof LivingEntity)) continue;
boolean hasFound = false;
for(EntityType type : types) {
if(type.is(ent)) {
hasFound = true;
break;
}
}
if (hasFound) {
double yOff = ((LivingEntity) ent).getEyeHeight();
Location k = LocationUtil.getCenterOfBlock(LocationUtil.getNextFreeSpace(getBackBlock(), BlockFace.UP));
Arrow ar = area.getWorld().spawnArrow(k, ent.getLocation().add(0, yOff, 0).subtract(k.clone().add(0.5,0.5,0.5)).toVector().normalize(), speed, 0);
if(!((LivingEntity)ent).hasLineOfSight(ar)) {
ar.remove();
continue;
}
break;
}
}