mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
bc127ea819
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: eec4aab0 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent 205213c6 SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron CraftBukkit Changes: b8c522d5 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent f04a77dc SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron d1dbcebc SPIGOT-6653: Canceling snow bucket placement removes snow from bucket 4f34a67b #891: Fix scheduler task ID overflow and duplication issues Spigot Changes: d03d7f12 BUILDTOOLS-604: Rebuild patches
85 lines
4.4 KiB
Diff
85 lines
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
Date: Wed, 29 May 2019 04:01:22 +0100
|
|
Subject: [PATCH] ChunkMapDistance CME
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
index 2b235508ffd01de14714de1a31c2139e7c15bd27..7af33e8c470e499b7ec47467cce7df699c96873a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
@@ -73,6 +73,7 @@ public class ChunkHolder {
|
|
private boolean resendLight;
|
|
private CompletableFuture<Void> pendingFullStateConfirmation;
|
|
|
|
+ boolean isUpdateQueued = false; // Paper
|
|
private final ChunkMap chunkMap; // Paper
|
|
|
|
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
|
|
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
|
index 48bb57d3a431ea466425eb7da821c0aea900bd4c..45c7ebe67019cdbe88b6617a95d5c40d3a68286c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
|
|
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
|
@@ -47,7 +47,16 @@ public abstract class DistanceManager {
|
|
private final DistanceManager.ChunkTicketTracker ticketTracker = new DistanceManager.ChunkTicketTracker();
|
|
private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8);
|
|
private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(33);
|
|
- final Set<ChunkHolder> chunksToUpdateFutures = Sets.newHashSet();
|
|
+ // Paper start use a queue, but still keep unique requirement
|
|
+ public final java.util.Queue<ChunkHolder> pendingChunkUpdates = new java.util.ArrayDeque<ChunkHolder>() {
|
|
+ @Override
|
|
+ public boolean add(ChunkHolder o) {
|
|
+ if (o.isUpdateQueued) return true;
|
|
+ o.isUpdateQueued = true;
|
|
+ return super.add(o);
|
|
+ }
|
|
+ };
|
|
+ // Paper end
|
|
final ChunkTaskPriorityQueueSorter ticketThrottler;
|
|
final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> ticketThrottlerInput;
|
|
final ProcessorHandle<ChunkTaskPriorityQueueSorter.Release> ticketThrottlerReleaser;
|
|
@@ -108,26 +117,14 @@ public abstract class DistanceManager {
|
|
;
|
|
}
|
|
|
|
- if (!this.chunksToUpdateFutures.isEmpty()) {
|
|
- // CraftBukkit start
|
|
- // Iterate pending chunk updates with protection against concurrent modification exceptions
|
|
- java.util.Iterator<ChunkHolder> iter = this.chunksToUpdateFutures.iterator();
|
|
- int expectedSize = this.chunksToUpdateFutures.size();
|
|
- do {
|
|
- ChunkHolder playerchunk = iter.next();
|
|
- iter.remove();
|
|
- expectedSize--;
|
|
-
|
|
- playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor);
|
|
-
|
|
- // Reset iterator if set was modified using add()
|
|
- if (this.chunksToUpdateFutures.size() != expectedSize) {
|
|
- expectedSize = this.chunksToUpdateFutures.size();
|
|
- iter = this.chunksToUpdateFutures.iterator();
|
|
- }
|
|
- } while (iter.hasNext());
|
|
- // CraftBukkit end
|
|
-
|
|
+ // Paper start
|
|
+ if (!this.pendingChunkUpdates.isEmpty()) {
|
|
+ while(!this.pendingChunkUpdates.isEmpty()) {
|
|
+ ChunkHolder remove = this.pendingChunkUpdates.remove();
|
|
+ remove.isUpdateQueued = false;
|
|
+ remove.updateFutures(playerchunkmap, this.mainThreadExecutor);
|
|
+ }
|
|
+ // Paper end
|
|
return true;
|
|
} else {
|
|
if (!this.ticketsToRelease.isEmpty()) {
|
|
@@ -385,7 +382,7 @@ public abstract class DistanceManager {
|
|
if (k != level) {
|
|
playerchunk = DistanceManager.this.updateChunkScheduling(id, level, playerchunk, k);
|
|
if (playerchunk != null) {
|
|
- DistanceManager.this.chunksToUpdateFutures.add(playerchunk);
|
|
+ DistanceManager.this.pendingChunkUpdates.add(playerchunk);
|
|
}
|
|
|
|
}
|