Skip to content

Commit

Permalink
Also throttle chunk unloading
Browse files Browse the repository at this point in the history
Fixes lag spikes after teleporting away from a previously loaded area.
  • Loading branch information
Johni0702 committed Jan 11, 2021
1 parent 3e51675 commit 6f1fa6f
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ public void update(BooleanSupplier shouldKeepTicking) {
// Anything remaining in the set is no longer needed and can now be unloaded
for (long chunkPos : toBeUnloaded) {
unload(ChunkPos.getPackedX(chunkPos), ChunkPos.getPackedZ(chunkPos), false);
if (!shouldKeepTicking.getAsBoolean()) {
break;
}
}

// Any jobs remaining in this set are no longer needed and can now be cancelled
for (long chunkPos : toBeCancelled){
LoadingJob loadingJob = loadingJobs.remove(chunkPos);
Expand Down

0 comments on commit 6f1fa6f

Please sign in to comment.