Improve Priority handling of neighbor chunks
Restores vanilla like behavior where neighbor chunks have less priority than the source chunk. This resolves the issue where teleporting sometimes has the chunk your arriving in slow to send. Also improves light tasks to always process tasks when tasks from the current priority level are collected instead of bundling them.
This commit is contained in:
parent
d151cf67a1
commit
b2381db24e
2 changed files with 11 additions and 11 deletions
|
@ -628,7 +628,7 @@ index 0b5ddff008d151ad03a1f382a8f24494356e8701..ff74be14512a947e81b62d53e616131c
|
|||
chunkData.addProperty("queued-for-unload", chunkMap.unloadQueue.contains(playerChunk.location.pair()));
|
||||
chunkData.addProperty("status", status == null ? "unloaded" : status.toString());
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
index 078cbc9f4dbd387ef1088c76b2f77ee47fff135d..c3621d9d410c23da5db024254311864680465125 100644
|
||||
index 078cbc9f4dbd387ef1088c76b2f77ee47fff135d..ca9e0208aa35c597a947485f67213ff4b1b1185f 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
@@ -1,6 +1,7 @@
|
||||
|
@ -687,7 +687,7 @@ index 078cbc9f4dbd387ef1088c76b2f77ee47fff135d..c3621d9d410c23da5db0242543118646
|
|||
+ }
|
||||
+
|
||||
+ private int getNeighborsPriority() {
|
||||
+ return neighborPriorities.isEmpty() ? getMyPriority() : getDemandedPriority();
|
||||
+ return (neighborPriorities.isEmpty() ? getMyPriority() : getDemandedPriority()) + 1;
|
||||
+ }
|
||||
+
|
||||
+ public void onNeighborRequest(PlayerChunk neighbor, ChunkStatus status) {
|
||||
|
@ -1237,7 +1237,7 @@ index f35dda50fd9015a793708d214c648d75f9f87e2b..ae1f9dde6887988ca682f53cba316ce5
|
|||
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) either.left().orElse(null);
|
||||
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index ff18c2d8c4752149ace290495d130e12baa52756..9a812b34698feb7d09f1063a913363b3ea6820eb 100644
|
||||
index e905aa4d668f51f0e0d2d140fcac54e5038aebfe..0c45159eb7747d943dc45efc60f5dc7d72b8f022 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -743,6 +743,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
|
|
@ -1027,7 +1027,7 @@ index a35e7b392c74fadf2760d1fc2021e98d33858cb5..944094e8e770cc8c0205ef2aa6c48fff
|
|||
lightenginelayer.a(Long.MAX_VALUE, l3, 15, false);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..fd0beefb900c064d3c35a3d2f79f5b7d9c1287bb 100644
|
||||
index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..2f9c97dd4e1d705a87772d18c7ab4883a876af08 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
@@ -1,6 +1,7 @@
|
||||
|
@ -1098,7 +1098,7 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..fd0beefb900c064d3c35a3d2f79f5b7d
|
|||
+ this.priorityChanges.add(() -> {
|
||||
+ ChunkLightQueue remove = this.buckets[currentPriority].remove(pair);
|
||||
+ if (remove != null) {
|
||||
+ ChunkLightQueue existing = this.buckets[priority].put(pair, remove);
|
||||
+ ChunkLightQueue existing = this.buckets[Math.max(1, priority)].put(pair, remove);
|
||||
+ if (existing != null) {
|
||||
+ remove.pre.addAll(existing.pre);
|
||||
+ remove.post.addAll(existing.post);
|
||||
|
@ -1151,12 +1151,12 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..fd0beefb900c064d3c35a3d2f79f5b7d
|
|||
+ }
|
||||
+ boolean hasWork = false;
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue>[] buckets = this.buckets;
|
||||
+ int lowestPriority = 0;
|
||||
+ while (lowestPriority < MAX_PRIORITIES && !isEmpty()) {
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue> bucket = buckets[lowestPriority];
|
||||
+ int priority = 0;
|
||||
+ while (priority < MAX_PRIORITIES && !isEmpty()) {
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue> bucket = buckets[priority];
|
||||
+ if (bucket.isEmpty()) {
|
||||
+ lowestPriority++;
|
||||
+ if (hasWork && lowestPriority <= 5) {
|
||||
+ priority++;
|
||||
+ if (hasWork) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ continue;
|
||||
|
@ -1329,7 +1329,7 @@ index ff00830b95a17f66d0c913087492dbf4b066df8a..4085426af03f032cf405bdfd1e40a8e5
|
|||
private static final int nibbleBucketSizeMultiplier = Integer.getInteger("Paper.nibbleBucketSize", 3072);
|
||||
private static final int maxPoolSize = Integer.getInteger("Paper.maxNibblePoolSize", (int) Math.min(6, Math.max(1, Runtime.getRuntime().maxMemory() / 1024 / 1024 / 1024)) * (nibbleBucketSizeMultiplier * 8));
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
index 1f14ebf09de9f2671b30498ea8fd66750ae85dff..de1e409dc5161371c6f14d036603be448fcd3e26 100644
|
||||
index 7de56172023e49cd8957e3dd45fa8e731809c16a..8146d88a90a758760e383985170d580372577615 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
@@ -724,6 +724,7 @@ public class PlayerChunk {
|
||||
|
|
Loading…
Reference in a new issue