From e33cd3cff2b8f3dd985740761cc72e5a0bc36d7c Mon Sep 17 00:00:00 2001 From: ishland Date: Mon, 28 Oct 2024 15:05:38 +0800 Subject: [PATCH] fix: bypass staging when adding player --- .../vmp/common/playerwatching/NearbyEntityTracking.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ishland/vmp/common/playerwatching/NearbyEntityTracking.java b/src/main/java/com/ishland/vmp/common/playerwatching/NearbyEntityTracking.java index c52836d..1c749fd 100644 --- a/src/main/java/com/ishland/vmp/common/playerwatching/NearbyEntityTracking.java +++ b/src/main/java/com/ishland/vmp/common/playerwatching/NearbyEntityTracking.java @@ -72,10 +72,6 @@ public static void init() { private final ObjectLinkedOpenHashSet stagingTrackers = new ObjectLinkedOpenHashSet<>(); private void addEntityTrackerAreaMap(ServerChunkLoadingManager.EntityTracker tracker) { - if (((IThreadedAnvilChunkStorageEntityTracker) tracker).getEntity() instanceof ServerPlayerEntity player) { - this.addPlayer(player); - } - // update is done lazily on next tickEntityMovement final ChunkPos pos = getEntityChunkPos(((IThreadedAnvilChunkStorageEntityTracker) tracker).getEntity()); this.areaMap.add( @@ -88,6 +84,9 @@ private void addEntityTrackerAreaMap(ServerChunkLoadingManager.EntityTracker tra } public void addEntityTracker(ServerChunkLoadingManager.EntityTracker tracker) { + if (((IThreadedAnvilChunkStorageEntityTracker) tracker).getEntity() instanceof ServerPlayerEntity player) { + this.addPlayer(player); + } if (Config.OPTIMIZED_ENTITY_TRACKING_USE_STAGING_AREA) { stagingTrackers.addAndMoveToLast(new StagedTracker(tracker, ticks.get())); for (ServerPlayerEntity player : this.playerTrackers.keySet()) { @@ -202,7 +201,7 @@ private void tickStaging(ServerChunkLoadingManager.TicketManager ticketManager) StagedTracker stagingTracker = iterator.next(); if (currentTicks - stagingTracker.tickAdded() >= STAGING_TRACKER_LIFETIME) { iterator.remove(); -// System.out.println(String.format("Migrating staging tracker %s", ((IThreadedAnvilChunkStorageEntityTracker) stagingTracker.tracker()).getEntity())); +// System.out.println(String.format("Migrating staging tracker %s", ((IThreadedAnvilChunkStorageEntityTracker) stagingTracker.tracker()).getEntity().getUuidAsString())); addEntityTrackerAreaMap(stagingTracker.tracker()); } else { break;