Properly remove manual viewers

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-11-25 21:30:58 +01:00
parent b637cd3059
commit e53c0a68fb
2 changed files with 7 additions and 0 deletions

View File

@ -878,6 +878,7 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
private void removeFromInstance(Instance instance) {
EventDispatcher.call(new RemoveEntityFromInstanceEvent(instance, this));
instance.getEntityTracker().unregister(this, position, trackingTarget, trackingUpdate);
this.viewEngine.forManuals(this::removeViewer);
}
/**

View File

@ -77,6 +77,12 @@ public final class ViewEngine {
}
}
public void forManuals(@NotNull Consumer<Player> consumer) {
synchronized (mutex) {
this.manualViewers.forEach(consumer);
}
}
public boolean hasPredictableViewers() {
// Verify if this entity's viewers can be predicted from surrounding entities
synchronized (mutex) {