private boolean isInFieldOfVision(LivingEntity e1, LivingEntity e2) {
Vector direction = e1.getEyeLocation().getDirection();
RayTraceResult result = e1.getWorld().rayTraceEntities(e1.getEyeLocation().add(direction).add(direction), direction, 10, 2,
(entity) -> entity.getUniqueId().toString().equalsIgnoreCase(e2.getUniqueId().toString()));
if (result == null)
return false;
return result.getHitEntity() != null;
}
Is there a more reliable method? It doesn't seem to work all the time






