2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-05-29 03:25:08 +00:00
|
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
Date: Wed, 29 May 2019 04:01:22 +0100
|
|
|
|
Subject: [PATCH] ChunkMapDistance CME
|
|
|
|
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMapDistance.java b/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
|
|
index 6ef404ee29ddc79aeca534a58ec182e0e8b1b6c8..961257ebc28a8b4753faf3c2d5b6abaea4ffc0dd 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
|
|
@@ -39,7 +39,16 @@ public abstract class ChunkMapDistance {
|
2020-06-25 14:09:55 +00:00
|
|
|
private final ChunkMapDistance.a ticketLevelTracker = new ChunkMapDistance.a();
|
2019-06-25 01:47:58 +00:00
|
|
|
private final ChunkMapDistance.b f = new ChunkMapDistance.b(8);
|
|
|
|
private final ChunkMapDistance.c g = new ChunkMapDistance.c(33);
|
2019-07-20 04:01:24 +00:00
|
|
|
- private final Set<PlayerChunk> pendingChunkUpdates = Sets.newHashSet();
|
2020-05-20 09:11:57 +00:00
|
|
|
+ // Paper start use a queue, but still keep unique requirement
|
|
|
|
+ public final java.util.Queue<PlayerChunk> pendingChunkUpdates = new java.util.ArrayDeque<PlayerChunk>() {
|
|
|
|
+ @Override
|
|
|
|
+ public boolean add(PlayerChunk o) {
|
|
|
|
+ if (o.isUpdateQueued) return true;
|
|
|
|
+ o.isUpdateQueued = true;
|
|
|
|
+ return super.add(o);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ // Paper end
|
2019-07-20 04:01:24 +00:00
|
|
|
private final ChunkTaskQueueSorter i;
|
2019-06-25 01:47:58 +00:00
|
|
|
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> j;
|
|
|
|
private final Mailbox<ChunkTaskQueueSorter.b> k;
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -100,26 +109,14 @@ public abstract class ChunkMapDistance {
|
2019-05-29 03:25:08 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2019-07-20 04:01:24 +00:00
|
|
|
if (!this.pendingChunkUpdates.isEmpty()) {
|
2019-07-16 22:09:32 +00:00
|
|
|
- // CraftBukkit start
|
|
|
|
- // Iterate pending chunk updates with protection against concurrent modification exceptions
|
2019-07-20 04:01:24 +00:00
|
|
|
- java.util.Iterator<PlayerChunk> iter = this.pendingChunkUpdates.iterator();
|
|
|
|
- int expectedSize = this.pendingChunkUpdates.size();
|
2019-07-16 22:09:32 +00:00
|
|
|
- do {
|
|
|
|
- PlayerChunk playerchunk = iter.next();
|
|
|
|
- iter.remove();
|
|
|
|
- expectedSize--;
|
|
|
|
-
|
2019-07-02 18:50:03 +00:00
|
|
|
- playerchunk.a(playerchunkmap);
|
2019-07-16 22:09:32 +00:00
|
|
|
-
|
|
|
|
- // Reset iterator if set was modified using add()
|
2019-07-20 04:01:24 +00:00
|
|
|
- if (this.pendingChunkUpdates.size() != expectedSize) {
|
|
|
|
- expectedSize = this.pendingChunkUpdates.size();
|
|
|
|
- iter = this.pendingChunkUpdates.iterator();
|
2019-07-16 22:09:32 +00:00
|
|
|
- }
|
|
|
|
- } while (iter.hasNext());
|
|
|
|
- // CraftBukkit end
|
|
|
|
-
|
2019-07-20 04:01:24 +00:00
|
|
|
+ while(!this.pendingChunkUpdates.isEmpty()) {
|
2020-05-20 09:11:57 +00:00
|
|
|
+ PlayerChunk remove = this.pendingChunkUpdates.remove();
|
|
|
|
+ remove.isUpdateQueued = false;
|
|
|
|
+ remove.a(playerchunkmap);
|
2019-07-02 18:50:03 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (!this.l.isEmpty()) {
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -373,7 +370,7 @@ public abstract class ChunkMapDistance {
|
2020-08-25 02:22:08 +00:00
|
|
|
ObjectIterator objectiterator = this.a.long2ByteEntrySet().iterator();
|
|
|
|
|
|
|
|
while (objectiterator.hasNext()) {
|
|
|
|
- it.unimi.dsi.fastutil.longs.Long2ByteMap.Entry it_unimi_dsi_fastutil_longs_long2bytemap_entry = (it.unimi.dsi.fastutil.longs.Long2ByteMap.Entry) objectiterator.next();
|
|
|
|
+ Long2ByteMap.Entry it_unimi_dsi_fastutil_longs_long2bytemap_entry = (Long2ByteMap.Entry) objectiterator.next(); // Paper - decompile fix
|
|
|
|
byte b0 = it_unimi_dsi_fastutil_longs_long2bytemap_entry.getByteValue();
|
|
|
|
long j = it_unimi_dsi_fastutil_longs_long2bytemap_entry.getLongKey();
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunk.java b/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
|
|
index 7dea5e783ce2a1f8ddd2b3ab7a19e03a56c36ba1..2c3d9a5d118cc4f3b5e78daf943911bb7386488a 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
|
|
@@ -45,6 +45,7 @@ public class PlayerChunk {
|
2020-05-20 09:11:57 +00:00
|
|
|
private static final CompletableFuture<Either<Chunk, PlayerChunk.Failure>> UNLOADED_CHUNK_FUTURE = CompletableFuture.completedFuture(PlayerChunk.UNLOADED_CHUNK);
|
|
|
|
private static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.a();
|
|
|
|
private static final PlayerChunk.State[] CHUNK_STATES = PlayerChunk.State.values();
|
|
|
|
+ boolean isUpdateQueued = false; // Paper
|
|
|
|
private final AtomicReferenceArray<CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>>> statusFutures;
|
|
|
|
private volatile CompletableFuture<Either<Chunk, PlayerChunk.Failure>> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage
|
|
|
|
private volatile CompletableFuture<Either<Chunk, PlayerChunk.Failure>> tickingFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage
|