Player#refreshVisibleEntities cleanup

This commit is contained in:
TheMode 2021-05-03 01:58:17 +02:00
parent cd0ea0c0c2
commit 748e3d7b39

View File

@ -1640,9 +1640,9 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
final float maximalDistance = entityViewDistance * Chunk.CHUNK_SECTION_SIZE; final float maximalDistance = entityViewDistance * Chunk.CHUNK_SECTION_SIZE;
// Manage already viewable entities // Manage already viewable entities
this.viewableEntities.forEach(entity -> { this.viewableEntities.stream()
final double distance = entity.getDistance(this); .filter(entity -> entity.getDistance(this) > maximalDistance)
if (distance > maximalDistance) { .forEach(entity -> {
// Entity shouldn't be viewable anymore // Entity shouldn't be viewable anymore
if (isAutoViewable()) { if (isAutoViewable()) {
entity.removeViewer(this); entity.removeViewer(this);
@ -1650,7 +1650,6 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
if (entity instanceof Player && entity.isAutoViewable()) { if (entity instanceof Player && entity.isAutoViewable()) {
removeViewer((Player) entity); removeViewer((Player) entity);
} }
}
}); });
// Manage entities in unchecked chunks // Manage entities in unchecked chunks