diff --git a/src/main/java/net/minestom/server/utils/ViewEngine.java b/src/main/java/net/minestom/server/utils/ViewEngine.java index cc707a8c6..b49e649ed 100644 --- a/src/main/java/net/minestom/server/utils/ViewEngine.java +++ b/src/main/java/net/minestom/server/utils/ViewEngine.java @@ -124,7 +124,7 @@ public final class ViewEngine { private final Predicate loopPredicate; // The consumers to be called when an entity is added/removed. public final Consumer addition, removal; - // Contains all the entity ids that are viewable by this option. + // Contains all the auto-entity ids that are viewable by this option. public final RoaringBitmap bitSet = new RoaringBitmap(); // 1 if auto, 0 if manual private volatile int auto = 1; @@ -277,7 +277,12 @@ public final class ViewEngine { public void forEach(Consumer action) { synchronized (mutex) { if (!manualViewers.isEmpty()) manualViewers.forEach(action); - // Auto + if (entity != null) { + viewableOption.bitSet.forEach((int id) -> + action.accept((Player) Entity.getEntity(id))); + return; + } + // Non-entity fallback final List> auto = ViewEngine.this.viewableOption.references; if (auto != null && viewableOption.isAuto()) { for (List players : auto) {