use a Queue in ChunkMapDistance

An oversight in this patch may be to blame for several issues in certain
cases, we'll opt to using a queue as this will fall in line with what is
expected and may help some issues where chunks remain loaded or fail to
load
This commit is contained in:
Shane Freeder 2019-07-02 19:50:03 +01:00
parent 63edda8ed6
commit c204872eb4
3 changed files with 24 additions and 14 deletions

View file

@ -185,7 +185,7 @@ index 391726d99c..8db92edc36 100644
* Ported from MinecraftForge - author: LexManos <LexManos@gmail.com> - License: LGPLv2.1
*/
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index cd18150488..0c562a5f34 100644
index f72843119a..c1fdd7b7a4 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -0,0 +0,0 @@ public abstract class ChunkMapDistance {

View file

@ -5,15 +5,23 @@ Subject: [PATCH] ChunkMapDistance CME
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index ed4e8d69ca..cd18150488 100644
index ed4e8d69ca..f72843119a 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
+
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -0,0 +0,0 @@ public abstract class ChunkMapDistance {
private final ChunkMapDistance.a e = new ChunkMapDistance.a();
private final ChunkMapDistance.b f = new ChunkMapDistance.b(8);
private final ChunkMapDistance.c g = new ChunkMapDistance.c(33);
- private final Set<PlayerChunk> h = Sets.newHashSet();
+ private Set<PlayerChunk> h = Sets.newHashSet(); // Paper - -final
+ private java.util.Queue<PlayerChunk> h = new java.util.LinkedList<>(); // Paper - -final
private final PlayerChunk.c i;
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> j;
private final Mailbox<ChunkTaskQueueSorter.b> k;
@ -21,15 +29,17 @@ index ed4e8d69ca..cd18150488 100644
;
}
- if (!this.h.isEmpty()) {
- this.h.forEach((playerchunk) -> {
+ // Paper start
+ Set<PlayerChunk> currentPending = this.h;
+ this.h = Sets.newHashSet();
+ if (!currentPending.isEmpty()) {
+ currentPending.forEach((playerchunk) -> {
+ // Paper end
playerchunk.a(playerchunkmap);
});
this.h.clear();
if (!this.h.isEmpty()) {
- this.h.forEach((playerchunk) -> {
- playerchunk.a(playerchunkmap);
- });
- this.h.clear();
+ while(!this.h.isEmpty()) {
+ this.h.remove().a(playerchunkmap);
+ }
+ // Paper end
return true;
} else {
if (!this.l.isEmpty()) {
--

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Fix MC-154214
Avoid adding player tickets when they're out of range of the closest player
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index 0c562a5f34..7a76db08fc 100644
index c1fdd7b7a4..1a6fe87cd8 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -0,0 +0,0 @@ public abstract class ChunkMapDistance {