Fixed issues with distance calculation

This commit is contained in:
Sollace 2020-05-04 00:41:22 +02:00
parent 0af0cb2182
commit 296d6dc255

View file

@ -60,8 +60,8 @@ public interface VecHelper {
static Stream<Entity> findAllEntitiesInRange(@Nullable Entity origin, World w, BlockPos pos, double radius) {
return w.getEntities(origin, new Box(pos).expand(radius), e -> {
double dist = e.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ());
double dist2 = e.squaredDistanceTo(pos.getX(), pos.getY() - e.getStandingEyeHeight(), pos.getZ());
double dist = Math.sqrt(e.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ()));
double dist2 = Math.sqrt(e.squaredDistanceTo(pos.getX(), pos.getY() - e.getStandingEyeHeight(), pos.getZ()));
return dist <= radius || dist2 <= radius;
}).stream();