mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 02:57:37 +01:00
properly update viewing references
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
6e6da5df06
commit
b87259f21b
@ -126,6 +126,11 @@ public class Entity implements Viewable, Tickable, Schedulable, TagHandler, Perm
|
||||
public void remove(@NotNull Entity entity) {
|
||||
viewEngine.handleAutoViewRemoval(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void referenceUpdate(@NotNull Point point, @Nullable EntityTracker tracker) {
|
||||
viewEngine.updateTracker(point, tracker);
|
||||
}
|
||||
};
|
||||
|
||||
protected final ViewEngine viewEngine = new ViewEngine(this,
|
||||
|
@ -147,6 +147,8 @@ public sealed interface EntityTracker permits EntityTrackerImpl {
|
||||
void add(@NotNull E entity);
|
||||
|
||||
void remove(@NotNull E entity);
|
||||
|
||||
void referenceUpdate(@NotNull Point point, @Nullable EntityTracker tracker);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,7 @@ final class EntityTrackerImpl implements EntityTracker {
|
||||
}
|
||||
}
|
||||
if (update != null) {
|
||||
update.referenceUpdate(point, this);
|
||||
visibleEntities(point, target, newEntity -> {
|
||||
if (newEntity == entity) return;
|
||||
update.add(newEntity);
|
||||
@ -64,6 +65,7 @@ final class EntityTrackerImpl implements EntityTracker {
|
||||
}
|
||||
}
|
||||
if (update != null) {
|
||||
update.referenceUpdate(point, null);
|
||||
visibleEntities(point, target, update::remove);
|
||||
}
|
||||
}
|
||||
@ -92,7 +94,13 @@ final class EntityTrackerImpl implements EntityTracker {
|
||||
public void remove(@NotNull T removed) {
|
||||
if (entity != removed) update.remove(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void referenceUpdate(@NotNull Point point, @Nullable EntityTracker tracker) {
|
||||
// Empty
|
||||
}
|
||||
});
|
||||
update.referenceUpdate(newPoint, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user