Updated Upstream (CraftBukkit)

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

CraftBukkit Changes:
cc7edd6bc SPIGOT-7051: Worldgen API does not run vanilla noise generation when shouldGenerateNoise is true
This commit is contained in:
Nassim Jahnke 2022-06-10 14:45:58 +02:00
parent 9a75a79edd
commit 07548192b1
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
36 changed files with 180 additions and 180 deletions

View File

@ -5304,7 +5304,7 @@ index f902b1f7062fc2c81e0ce43e8b8599192469e57c..90fcb4dc89643b1c706ea4554595a842
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc430530ca 100644
index 3e49e739238096442e89b7ab23d2af8aff55912e..91fd4243416c41b1c2b0f0f1abc154064c164a25 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -62,6 +62,7 @@ import net.minecraft.network.protocol.game.ClientboundSetChunkCacheCenterPacket;
@ -5315,7 +5315,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.util.CsvOutput;
@@ -167,6 +168,56 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -168,6 +169,56 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
};
// CraftBukkit end
@ -5372,7 +5372,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -211,6 +262,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -217,6 +268,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.overworldDataStorage = persistentStateManagerFactory;
this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, world.registryAccess(), world);
this.setViewDistance(viewDistance);
@ -5383,7 +5383,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
}
protected ChunkGenerator generator() {
@@ -304,6 +359,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -310,6 +365,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}
@ -5398,7 +5398,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
private CompletableFuture<Either<List<ChunkAccess>, ChunkHolder.ChunkLoadingFailure>> getChunkRangeFuture(ChunkPos centerChunk, int margin, IntFunction<ChunkStatus> distanceToStatus) {
List<CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> list = new ArrayList();
List<ChunkHolder> list1 = new ArrayList();
@@ -435,6 +498,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -441,6 +504,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
holder.setTicketLevel(level);
} else {
holder = new ChunkHolder(new ChunkPos(pos), level, this.level, this.lightEngine, this.queueSorter, this);
@ -5410,7 +5410,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
}
this.updatingChunkMap.put(pos, holder);
@@ -552,7 +620,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -558,7 +626,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (completablefuture1 != completablefuture) {
this.scheduleUnload(pos, holder);
} else {
@ -5425,7 +5425,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
if (ichunkaccess instanceof LevelChunk) {
((LevelChunk) ichunkaccess).setLoaded(false);
}
@@ -568,7 +642,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -574,7 +648,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lightEngine.tryScheduleUpdate();
this.progressListener.onStatusChange(ichunkaccess.getPos(), (ChunkStatus) null);
this.chunkSaveCooldowns.remove(ichunkaccess.getPos().toLong());
@ -5437,7 +5437,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
}
};
@@ -1138,6 +1216,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1144,6 +1222,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!flag1) {
this.distanceManager.addPlayer(SectionPos.of((EntityAccess) player), player);
}
@ -5445,7 +5445,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
} else {
SectionPos sectionposition = player.getLastSectionPos();
@@ -1145,6 +1224,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1151,6 +1230,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!flag2) {
this.distanceManager.removePlayer(sectionposition, player);
}
@ -5453,7 +5453,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
}
for (int k = i - this.viewDistance - 1; k <= i + this.viewDistance + 1; ++k) {
@@ -1257,6 +1337,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1263,6 +1343,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}
@ -5462,7 +5462,7 @@ index 775e34f6abd2fd703a284a85d975d48cd1930ad9..ef23f9f81a909348ee4ae3d7eb51dbcc
}
@Override
@@ -1460,7 +1542,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1466,7 +1548,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public class ChunkDistanceManager extends DistanceManager {
protected ChunkDistanceManager(Executor workerExecutor, Executor mainThreadExecutor) {

View File

@ -997,7 +997,7 @@ index 408eff59b081ace53bf435947df17e2fe75bfd5e..cd0365249dffc1704a349a5e419364bb
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ef23f9f81a909348ee4ae3d7eb51dbcc430530ca..e9a2a71b1f2bf6c701d4eba8dc31a10015cf7904 100644
index 91fd4243416c41b1c2b0f0f1abc154064c164a25..e01d86c50e0227cfae91ba8022b763e51a10c5f5 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1,8 +1,10 @@
@ -1011,7 +1011,7 @@ index ef23f9f81a909348ee4ae3d7eb51dbcc430530ca..e9a2a71b1f2bf6c701d4eba8dc31a100
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
@@ -847,6 +849,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -853,6 +855,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
ChunkStatus chunkstatus = ChunkHolder.getStatus(chunkHolder.getTicketLevel());
return !chunkstatus.isOrAfter(ChunkStatus.FULL) ? ChunkHolder.UNLOADED_CHUNK : either.mapLeft((ichunkaccess) -> {
@ -1019,7 +1019,7 @@ index ef23f9f81a909348ee4ae3d7eb51dbcc430530ca..e9a2a71b1f2bf6c701d4eba8dc31a100
ChunkPos chunkcoordintpair = chunkHolder.getPos();
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
LevelChunk chunk;
@@ -871,6 +874,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -877,6 +880,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
return chunk;
@ -1027,7 +1027,7 @@ index ef23f9f81a909348ee4ae3d7eb51dbcc430530ca..e9a2a71b1f2bf6c701d4eba8dc31a100
});
}, (runnable) -> {
ProcessorHandle mailbox = this.mainThreadMailbox;
@@ -1423,6 +1427,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1429,6 +1433,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players();
ObjectIterator objectiterator = this.entityMap.values().iterator();
@ -1035,7 +1035,7 @@ index ef23f9f81a909348ee4ae3d7eb51dbcc430530ca..e9a2a71b1f2bf6c701d4eba8dc31a100
ChunkMap.TrackedEntity playerchunkmap_entitytracker;
@@ -1447,14 +1452,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1453,14 +1458,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
playerchunkmap_entitytracker.serverEntity.sendChanges();
}
}

View File

@ -49,10 +49,10 @@ index 0000000000000000000000000000000000000000..f699ce18ca044f813e194ef2786b7ea8
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e9a2a71b1f2bf6c701d4eba8dc31a10015cf7904..8b11fbfe2805ad7e8ba84e6b7fdfafc054a248bd 100644
index e01d86c50e0227cfae91ba8022b763e51a10c5f5..e1200e903e39c3e5cb023e1bd4fe104907c0c6eb 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -992,6 +992,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -998,6 +998,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return true;
} catch (Exception exception) {
ChunkMap.LOGGER.error("Failed to save chunk {},{}", new Object[]{chunkcoordintpair.x, chunkcoordintpair.z, exception});
@ -100,7 +100,7 @@ index c6fb4c33d7ea52b88d8fc0d90748cbab7387c565..fed09b886f4fa0006d160e5f2abb00df
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 17da97bfece600438f6e872e8a1a2bee1d60c804..447ce111786a53fca6b0f6c8803b47f9cadd7df7 100644
index 7b3a81876f04c6aff370ac9cc97b0c9270f34a2e..ee71a6cc552bd2bb82beda1bd44905ea4cc14604 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1,5 +1,10 @@

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8b11fbfe2805ad7e8ba84e6b7fdfafc054a248bd..943cad9a08d72b90b92f92ef90588501bbf158d5 100644
index e1200e903e39c3e5cb023e1bd4fe104907c0c6eb..702d885b6a5caf8cabc40934893a081b01906781 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -231,7 +231,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -232,7 +232,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.entityMap = new Int2ObjectOpenHashMap();
this.chunkTypeCache = new Long2ByteOpenHashMap();
this.chunkSaveCooldowns = new Long2LongOpenHashMap();
@ -17,7 +17,7 @@ index 8b11fbfe2805ad7e8ba84e6b7fdfafc054a248bd..943cad9a08d72b90b92f92ef90588501
this.structureTemplateManager = structureTemplateManager;
Path path = session.getDimensionPath(world.dimension());
@@ -581,7 +581,6 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -587,7 +587,6 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private void processUnloads(BooleanSupplier shouldKeepTicking) {
LongIterator longiterator = this.toDrop.iterator();
@ -25,7 +25,7 @@ index 8b11fbfe2805ad7e8ba84e6b7fdfafc054a248bd..943cad9a08d72b90b92f92ef90588501
for (int i = 0; longiterator.hasNext() && (shouldKeepTicking.getAsBoolean() || i < 200 || this.toDrop.size() > 2000); longiterator.remove()) {
long j = longiterator.nextLong();
ChunkHolder playerchunk = (ChunkHolder) this.updatingChunkMap.remove(j);
@@ -594,7 +593,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -600,7 +599,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}

View File

@ -9,10 +9,10 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 943cad9a08d72b90b92f92ef90588501bbf158d5..f9ef45635b731cafc9b6879603cac34c146833b0 100644
index 702d885b6a5caf8cabc40934893a081b01906781..4f2dfe5d2b646a1a2f19414388af13b26d28d504 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1150,7 +1150,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1156,7 +1156,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
chunkRange = (chunkRange > 8) ? 8 : chunkRange;
@ -23,7 +23,7 @@ index 943cad9a08d72b90b92f92ef90588501bbf158d5..f9ef45635b731cafc9b6879603cac34c
// Spigot end
long i = chunkcoordintpair.toLong();
@@ -1167,6 +1169,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1173,6 +1175,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
entityplayer = (ServerPlayer) iterator.next();

View File

@ -8,10 +8,10 @@ Add -Ddebug.entities=true to your JVM flags to gain more information
1.17: Needs to be reworked for new entity storage system
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f9ef45635b731cafc9b6879603cac34c146833b0..29482bebf5b878c698283720d1452ef237da5516 100644
index 4f2dfe5d2b646a1a2f19414388af13b26d28d504..213c94cecc1103056ce83625f1e78cd62b6476a6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1389,6 +1389,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1395,6 +1395,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} else {
ChunkMap.TrackedEntity playerchunkmap_entitytracker = new ChunkMap.TrackedEntity(entity, i, j, entitytypes.trackDeltas());
@ -19,7 +19,7 @@ index f9ef45635b731cafc9b6879603cac34c146833b0..29482bebf5b878c698283720d1452ef2
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
playerchunkmap_entitytracker.updatePlayers(this.level.players());
if (entity instanceof ServerPlayer) {
@@ -1431,7 +1432,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1437,7 +1438,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (playerchunkmap_entitytracker1 != null) {
playerchunkmap_entitytracker1.broadcastRemoved();
}

View File

@ -2291,10 +2291,10 @@ index e3f43c2b6ff47f6a8c158d176dfc2c5a3fa66a62..7bec6d7b376e382c6266456314eda3ea
public String getLocalIp() {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7bc550411b 100644
index 213c94cecc1103056ce83625f1e78cd62b6476a6..b289d6c166625947fb2abb4159bbec651a1067f3 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -519,6 +519,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -525,6 +525,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void close() throws IOException {
try {
this.queueSorter.close();
@ -2302,7 +2302,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
this.poiManager.close();
} finally {
super.close();
@@ -555,7 +556,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -561,7 +562,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.processUnloads(() -> {
return true;
});
@ -2312,7 +2312,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
} else {
this.visibleChunkMap.values().forEach(this::saveChunkIfNeeded);
}
@@ -565,11 +567,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -571,11 +573,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
protected void tick(BooleanSupplier shouldKeepTicking) {
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
@ -2328,7 +2328,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
}
gameprofilerfiller.pop();
@@ -632,7 +638,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -638,7 +644,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
((LevelChunk) ichunkaccess).setLoaded(false);
}
@ -2346,7 +2346,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
if (this.entitiesInLevel.remove(pos) && ichunkaccess instanceof LevelChunk) {
LevelChunk chunk = (LevelChunk) ichunkaccess;
@@ -698,32 +713,54 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -704,32 +719,54 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
private CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> scheduleChunkLoad(ChunkPos pos) {
@ -2420,7 +2420,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
return nbt.contains("Status", 8);
}
@@ -962,7 +999,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -968,7 +1005,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}
@ -2469,7 +2469,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
this.poiManager.flush(chunk.getPos());
if (!chunk.isUnsaved()) {
return false;
@@ -974,7 +1052,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -980,7 +1058,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
ChunkStatus chunkstatus = chunk.getStatus();
if (chunkstatus.getChunkType() != ChunkStatus.ChunkType.LEVELCHUNK) {
@ -2478,7 +2478,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
return false;
}
@@ -984,9 +1062,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -990,9 +1068,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
this.level.getProfiler().incrementCounter("chunkSave");
@ -2496,7 +2496,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
this.markPosition(chunkcoordintpair, chunkstatus.getChunkType());
return true;
} catch (Exception exception) {
@@ -995,6 +1079,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1001,6 +1085,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return false;
}
}
@ -2504,7 +2504,7 @@ index 29482bebf5b878c698283720d1452ef237da5516..9b0ad38bacf9bb3e15106f5822389e7b
}
private boolean isExistingChunkFull(ChunkPos pos) {
@@ -1128,6 +1213,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1134,6 +1219,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}

View File

@ -8,10 +8,10 @@ This patch also adds a chunk status cache on region files (note that
its only purpose is to cache the status on DISK)
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 9b0ad38bacf9bb3e15106f5822389e7bc550411b..ef7ef7fa4116e0def1d73e604ee706deb4c94330 100644
index b289d6c166625947fb2abb4159bbec651a1067f3..b6407f47e1be630f93ad185d56304f0ecbada6eb 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1243,9 +1243,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1249,9 +1249,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end
private CompletableFuture<Optional<CompoundTag>> readChunk(ChunkPos chunkPos) {
@ -28,7 +28,7 @@ index 9b0ad38bacf9bb3e15106f5822389e7bc550411b..ef7ef7fa4116e0def1d73e604ee706de
}
// CraftBukkit start
@@ -1254,6 +1258,63 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1260,6 +1264,63 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// CraftBukkit end
}

View File

@ -33,7 +33,7 @@ But for those who are ok with leaving this inconsistent behavior, you may use WA
It is recommended you regenerate the entities, as these were legit entities, and deserve your love.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ef7ef7fa4116e0def1d73e604ee706deb4c94330..ac57c9f6ac5c0bf816a9adaee8ecbb5d291926d9 100644
index b6407f47e1be630f93ad185d56304f0ecbada6eb..375f66bf1617e255b3465b736076a65e080eb36e 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -32,13 +32,17 @@ import java.io.Writer;
@ -54,7 +54,7 @@ index ef7ef7fa4116e0def1d73e604ee706deb4c94330..ac57c9f6ac5c0bf816a9adaee8ecbb5d
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
@@ -871,6 +875,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -877,6 +881,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.discard();
needsRemoval = true;
}
@ -62,7 +62,7 @@ index ef7ef7fa4116e0def1d73e604ee706deb4c94330..ac57c9f6ac5c0bf816a9adaee8ecbb5d
return !needsRemoval;
}));
// CraftBukkit end
@@ -921,6 +926,43 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -927,6 +932,43 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
});
}

View File

@ -7,7 +7,7 @@ This lets you run /paper fixlight <chunkRadius> (max 5) to automatically
fix all light data in the chunks.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index a110be5e3f3f168a6557cd935de20aeadac5b942..7ed91424ff9185bf8c06a034e880f83681f7d019 100644
index 527b37e2740d6ca0d8d7695f069111d156c74b66..c1c95d6abfc7f1698a74387319ff90ad3a7e39af 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -12,7 +12,8 @@ import net.minecraft.server.MinecraftServer;
@ -134,10 +134,10 @@ index a110be5e3f3f168a6557cd935de20aeadac5b942..7ed91424ff9185bf8c06a034e880f836
+ }
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ac57c9f6ac5c0bf816a9adaee8ecbb5d291926d9..c4af6e0f38ac9271247ed657b8ee6b48822417b5 100644
index 375f66bf1617e255b3465b736076a65e080eb36e..d95db45e21861eb9f1623c44dd797429ae158760 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -140,6 +140,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -141,6 +141,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final ChunkTaskPriorityQueueSorter queueSorter;
private final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> worldgenMailbox;
public final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> mainThreadMailbox;
@ -150,7 +150,7 @@ index ac57c9f6ac5c0bf816a9adaee8ecbb5d291926d9..c4af6e0f38ac9271247ed657b8ee6b48
public final ChunkProgressListener progressListener;
private final ChunkStatusUpdateListener chunkStatusListener;
public final ChunkMap.ChunkDistanceManager distanceManager;
@@ -258,11 +264,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -264,11 +270,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.progressListener = worldGenerationProgressListener;
this.chunkStatusListener = chunkStatusChangeListener;

View File

@ -1119,10 +1119,10 @@ index 7825d6f0fdcfda6212cff8033ec55fb7db236154..2072aa8710f6e285f7c8f76c63b7bcf8
public ClientboundLevelChunkWithLightPacket(FriendlyByteBuf buf) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index c4af6e0f38ac9271247ed657b8ee6b48822417b5..7996247c00bf6ea4399322d089821432333ca6c4 100644
index d95db45e21861eb9f1623c44dd797429ae158760..1c3dacd12ff5f26dd5559d0b99c917a0be3b4d6a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -991,7 +991,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -997,7 +997,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
completablefuture1.thenAcceptAsync((either) -> {
either.ifLeft((chunk) -> {
this.tickingGenerated.getAndIncrement();
@ -1131,7 +1131,7 @@ index c4af6e0f38ac9271247ed657b8ee6b48822417b5..7996247c00bf6ea4399322d089821432
this.getPlayers(chunkcoordintpair, false).forEach((entityplayer) -> {
this.playerLoadedChunk(entityplayer, mutableobject, chunk);
@@ -1170,7 +1170,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1176,7 +1176,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
while (objectiterator.hasNext()) {
ChunkHolder playerchunk = (ChunkHolder) objectiterator.next();
ChunkPos chunkcoordintpair = playerchunk.getPos();
@ -1140,7 +1140,7 @@ index c4af6e0f38ac9271247ed657b8ee6b48822417b5..7996247c00bf6ea4399322d089821432
this.getPlayers(chunkcoordintpair, false).forEach((entityplayer) -> {
SectionPos sectionposition = entityplayer.getLastSectionPos();
@@ -1184,7 +1184,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1190,7 +1190,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
@ -1149,7 +1149,7 @@ index c4af6e0f38ac9271247ed657b8ee6b48822417b5..7996247c00bf6ea4399322d089821432
if (player.level == this.level) {
if (newWithinViewDistance && !oldWithinViewDistance) {
ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos.toLong());
@@ -1721,12 +1721,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1727,12 +1727,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}

View File

@ -8,10 +8,10 @@ Sets tracking range of watermobs to animals instead of misc and simplifies code
Also ignores Enderdragon, defaulting it to Mojang's setting
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 7996247c00bf6ea4399322d089821432333ca6c4..7983fbc003ca0904dc1a0a9c45d43502a44131a7 100644
index 1c3dacd12ff5f26dd5559d0b99c917a0be3b4d6a..60d47c0afa0b0dd8898193099e3a6c3e109c0817 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1909,6 +1909,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1915,6 +1915,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
int j = entity.getType().clientTrackingRange() * 16;

View File

@ -252,10 +252,10 @@ index 0000000000000000000000000000000000000000..11de56afaf059b00fa5bec293516bcdc
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 7983fbc003ca0904dc1a0a9c45d43502a44131a7..492e073cfc2a43951e20fd2d15a576601e84a364 100644
index 60d47c0afa0b0dd8898193099e3a6c3e109c0817..43011f5e8cbdf28400701465dd6e1614506d4ece 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -158,6 +158,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -159,6 +159,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final Long2LongMap chunkSaveCooldowns;
private final Queue<Runnable> unloadQueue;
int viewDistance;
@ -263,7 +263,7 @@ index 7983fbc003ca0904dc1a0a9c45d43502a44131a7..492e073cfc2a43951e20fd2d15a57660
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
@@ -187,16 +188,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -188,16 +189,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated
@ -295,7 +295,7 @@ index 7983fbc003ca0904dc1a0a9c45d43502a44131a7..492e073cfc2a43951e20fd2d15a57660
}
// Paper end
// Paper start
@@ -279,6 +295,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -285,6 +301,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
this.regionManagers.add(this.dataRegionManager);
// Paper end
@ -303,7 +303,7 @@ index 7983fbc003ca0904dc1a0a9c45d43502a44131a7..492e073cfc2a43951e20fd2d15a57660
}
protected ChunkGenerator generator() {
@@ -300,6 +317,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -306,6 +323,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
});
}

View File

@ -7,10 +7,10 @@ Suspected case would be around the technique used in .stopRiding
Stack will identify any causer of this and warn instead of crashing.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 492e073cfc2a43951e20fd2d15a576601e84a364..1290f55259a5ba0b855323ba59a1d9b8d5de0f57 100644
index 43011f5e8cbdf28400701465dd6e1614506d4ece..8d99c45e10da9d8a54a12b1039515da05bd56f6b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1642,6 +1642,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1648,6 +1648,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void addEntity(Entity entity) {
org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot

View File

@ -71,7 +71,7 @@ index 8cc4cb2163a93b9491550fe6d0f5d980fb216920..4dd14d73a37b32288a64fbd67ee22c43
cause = cause.getCause();
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7de1368bcde500ba133282537270fbdfd9c9d54b..60648e7c3c86176631d9a3ffdf21f6d236eabd79 100644
index f69ed252f55623ee5cba6ac9d28096c2cc92ea04..691fbbb720a3a58aa4e0daee715e9ce36d37ec4c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -281,7 +281,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -262,10 +262,10 @@ index f33f38c3c8c277d208b00b64e1d0fa7bb5eda7ec..e585cdd8a598df2b04c265d5568f8ba8
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1290f55259a5ba0b855323ba59a1d9b8d5de0f57..1bdfac38a40e5406d8c3f3b4ddd018031bee7ef4 100644
index 8d99c45e10da9d8a54a12b1039515da05bd56f6b..42645114b270b1e7c2b3112abd7eaa90d0e4451c 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -586,6 +586,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -592,6 +592,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
MutableBoolean mutableboolean = new MutableBoolean();
do {
@ -323,7 +323,7 @@ index 89f4ea65b20e773bd3782c41db3a2af7b5b405f3..3fe94e580d2aaae9616ba83c0d3a4468
final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
net.minecraft.server.MinecraftServer.LOGGER.error(msg, throwable);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f83d09866176f6d8fd9549f82cf743312b3df000..d19729adffd3b077c7fce4c6e53d30b98936368f 100644
index 943060b67d962a53bba8c2caa39de435060e036d..10d81c2300b17b9d8981450fc03915dba7f458d1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2049,7 +2049,7 @@ public final class CraftServer implements Server {

View File

@ -25,10 +25,10 @@ This successfully fixed a reoccurring and highly reproducible crash
for heightmaps.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1bdfac38a40e5406d8c3f3b4ddd018031bee7ef4..474d08e649dcdf7b9cab34e44c3e976dfba8f14b 100644
index 42645114b270b1e7c2b3112abd7eaa90d0e4451c..6354b100499b277c0949c65d454e84da6bce6aa8 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -181,6 +181,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -182,6 +182,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
};
// CraftBukkit end
@ -36,7 +36,7 @@ index 1bdfac38a40e5406d8c3f3b4ddd018031bee7ef4..474d08e649dcdf7b9cab34e44c3e976d
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@@ -1020,16 +1021,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1026,16 +1027,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
});
CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
return either.mapLeft((list) -> {

View File

@ -28,10 +28,10 @@ receives a deterministic result, and should no longer require 1 tick
delays anymore.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 474d08e649dcdf7b9cab34e44c3e976dfba8f14b..ac846039c98ed297dcb913ef4a02d4ab259debd2 100644
index 6354b100499b277c0949c65d454e84da6bce6aa8..4aebad2b6a7b70b335b7aa1d87d7d2383861e587 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1650,6 +1650,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1656,6 +1656,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
.printStackTrace();
return;
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Reduce allocation of Vec3D by entity tracker
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ac846039c98ed297dcb913ef4a02d4ab259debd2..eaee840359e13914865433a78e683ce3c4196956 100644
index 4aebad2b6a7b70b335b7aa1d87d7d2383861e587..fa6329b04ca185c7b12f2d782f109b94b19f9cc6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1928,9 +1928,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1934,9 +1934,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void updatePlayer(ServerPlayer player) {
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
if (player != this.entity) {

View File

@ -42,10 +42,10 @@ index 6e7d09cd48048957a14835b857ac708aafe8f664..4e8a79f2d3b6f52c6284bc9b0ce2423d
// Paper start
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018afaa37e1 100644
index fa6329b04ca185c7b12f2d782f109b94b19f9cc6..37ed4429e065b0e05f14ed352e191863a3547311 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -184,11 +184,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -185,11 +185,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final CallbackExecutor chunkLoadConversionCallbackExecutor = new CallbackExecutor(); // Paper
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@ -69,7 +69,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.add(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -198,6 +210,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -199,6 +211,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
void removePlayerFromDistanceMaps(ServerPlayer player) {
@ -80,7 +80,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.remove(player);
@@ -209,6 +225,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -210,6 +226,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated
@ -88,7 +88,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.update(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -297,6 +314,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -303,6 +320,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager);
// Paper end
this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
@ -127,7 +127,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
}
protected ChunkGenerator generator() {
@@ -552,6 +601,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -558,6 +607,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
holder = (ChunkHolder) this.pendingUnloads.remove(pos);
if (holder != null) {
holder.setTicketLevel(level);
@ -135,7 +135,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
} else {
holder = new ChunkHolder(new ChunkPos(pos), level, this.level, this.lightEngine, this.queueSorter, this);
// Paper start
@@ -647,6 +697,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -653,6 +703,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
ChunkHolder playerchunk = (ChunkHolder) this.updatingChunkMap.remove(j);
if (playerchunk != null) {
@ -143,7 +143,7 @@ index eaee840359e13914865433a78e683ce3c4196956..11c0e832c6f81b8f82795913393d2018
this.pendingUnloads.put(j, playerchunk);
this.modified = true;
++i;
@@ -1412,43 +1463,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1418,43 +1469,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(pos, false);
}

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd3641449adeb 100644
index 37ed4429e065b0e05f14ed352e191863a3547311..10ef89963ad805c775b9c649f4e17c9d4ec7f4b7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -69,6 +69,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
@ -17,7 +17,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.util.CsvOutput;
@@ -195,10 +196,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -196,10 +197,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap; // this map is absent from updateMaps since it's controlled at the start of the chunkproviderserver tick
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -53,7 +53,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
// Note: players need to be explicitly added to distance maps before they can be updated
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
// Paper start - per player mob spawning
@@ -210,6 +236,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -211,6 +237,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
void removePlayerFromDistanceMaps(ServerPlayer player) {
@ -65,7 +65,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player);
@@ -225,6 +256,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -226,6 +257,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated
@ -80,7 +80,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
@@ -314,6 +353,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -320,6 +359,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager);
// Paper end
this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
@ -126,7 +126,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
@@ -1586,17 +1664,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1592,17 +1670,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
public void move(ServerPlayer player) {
@ -145,7 +145,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
int i = SectionPos.blockToSectionCoord(player.getBlockX());
int j = SectionPos.blockToSectionCoord(player.getBlockZ());
@@ -1723,7 +1791,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1729,7 +1797,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
@ -154,7 +154,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1767,7 +1835,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1773,7 +1841,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = null; // Paper - We're no longer tracked
}
@ -192,7 +192,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players();
ObjectIterator objectiterator = this.entityMap.values().iterator();
@@ -1843,23 +1941,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1849,23 +1947,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos());
List<Entity> list = Lists.newArrayList();
List<Entity> list1 = Lists.newArrayList();
@ -236,7 +236,7 @@ index 11c0e832c6f81b8f82795913393d2018afaa37e1..5e387419d0163333f2370b5708fbd364
Iterator iterator;
Entity entity1;
@@ -1935,6 +2041,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1941,6 +2047,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lastSectionPos = SectionPos.of((EntityAccess) entity);
}

View File

@ -120,7 +120,7 @@ index 4e8a79f2d3b6f52c6284bc9b0ce2423dc43a154f..36a9d52d9af3bc398010c52dc16ab23e
for (int i = 0; i < this.futures.length(); ++i) {
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i);
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a897114ee273c1 100644
index 10ef89963ad805c775b9c649f4e17c9d4ec7f4b7..eb74a831fc439c56fe1ac2d4769ebefa1e5759a3 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -106,6 +106,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
@ -131,7 +131,7 @@ index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a89711
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger;
@@ -709,6 +710,64 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -715,6 +716,64 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
@ -196,7 +196,7 @@ index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a89711
protected void saveAllChunks(boolean flush) {
if (flush) {
List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList());
@@ -793,13 +852,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -799,13 +858,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
int l = 0;
@ -211,7 +211,7 @@ index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a89711
}
@@ -837,6 +890,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -843,6 +896,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.level.unload(chunk);
}
@ -219,7 +219,7 @@ index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a89711
this.lightEngine.updateChunkStatus(ichunkaccess.getPos());
this.lightEngine.tryScheduleUpdate();
@@ -1257,6 +1311,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1263,6 +1317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
asyncSaveData, chunk);
chunk.setUnsaved(false);
@ -227,7 +227,7 @@ index 5e387419d0163333f2370b5708fbd3641449adeb..3022b04038821d471503297628a89711
}
// Paper end
@@ -1266,6 +1321,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1272,6 +1327,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!chunk.isUnsaved()) {
return false;
} else {

View File

@ -23,7 +23,7 @@ Chunks in front of the player have higher priority, to help with
fast traveling players keep up with their movement.
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
index 5b3ef259cf1bff7b23654c2a3e9fc96a7ebc9a03..21f37cf2b0e716e606d1b012ec02580413dc4b3f 100644
index af40e473521f408aa0e112953c43bdbce164a48b..68860a3b6db2aa50373d71aec9502c18d48ab8b9 100644
--- a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
@@ -107,7 +107,7 @@ public final class ChunkTaskManager {
@ -360,10 +360,10 @@ index 36a9d52d9af3bc398010c52dc16ab23e53f2702a..ece4cd0de061969d4d2f07560e6cf38e
return this.isEntityTickingReady;
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e54e889b24 100644
index eb74a831fc439c56fe1ac2d4769ebefa1e5759a3..349c311e70758d99ebb4c61ad509a3a975fda04b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -133,6 +133,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -134,6 +134,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final ServerLevel level;
private final ThreadedLevelLightEngine lightEngine;
private final BlockableEventLoop<Runnable> mainThreadExecutor;
@ -371,7 +371,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
public ChunkGenerator generator;
private RandomState randomState;
public final Supplier<DimensionDataStorage> overworldDataStorage;
@@ -331,6 +332,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -337,6 +338,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
this.mainThreadExecutor = mainThreadExecutor;
@ -387,7 +387,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
ProcessorMailbox<Runnable> threadedmailbox = ProcessorMailbox.create(executor, "worldgen");
Objects.requireNonNull(mainThreadExecutor);
@@ -446,6 +456,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -452,6 +462,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
});
}
@ -425,7 +425,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
// Paper start
public void updatePlayerMobTypeMap(Entity entity) {
if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
@@ -556,6 +597,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -562,6 +603,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
List<ChunkHolder> list1 = new ArrayList();
int j = centerChunk.x;
int k = centerChunk.z;
@ -433,7 +433,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
for (int l = -margin; l <= margin; ++l) {
for (int i1 = -margin; i1 <= margin; ++i1) {
@@ -574,6 +616,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -580,6 +622,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
ChunkStatus chunkstatus = (ChunkStatus) distanceToStatus.apply(j1);
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = playerchunk.getOrScheduleFuture(chunkstatus, this);
@ -448,7 +448,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
list1.add(playerchunk);
list.add(completablefuture);
@@ -931,11 +981,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -937,11 +987,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (requiredStatus == ChunkStatus.EMPTY) {
return this.scheduleChunkLoad(chunkcoordintpair);
} else {
@ -469,7 +469,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
if (optional.isPresent() && ((ChunkAccess) optional.get()).getStatus().isOrAfter(requiredStatus)) {
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = requiredStatus.load(this.level, this.structureTemplateManager, this.lightEngine, (ichunkaccess) -> {
@@ -947,6 +1005,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -953,6 +1011,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} else {
return this.scheduleChunkGeneration(holder, requiredStatus);
}
@ -477,7 +477,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
}
}
@@ -986,14 +1045,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -992,14 +1051,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
};
CompletableFuture<CompoundTag> chunkSaveFuture = this.level.asyncChunkTaskManager.getChunkSaveFuture(pos.x, pos.z);
@ -507,7 +507,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
return ret;
// Paper end - Async chunk io
}
@@ -1072,7 +1141,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1078,7 +1147,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.releaseLightTicket(chunkcoordintpair);
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
});
@ -519,7 +519,7 @@ index 3022b04038821d471503297628a897114ee273c1..dc000f7ecefdd5013c91cf37db4a15e5
}
protected void releaseLightTicket(ChunkPos pos) {
@@ -1156,7 +1228,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1162,7 +1234,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
long i = chunkHolder.getPos().toLong();
Objects.requireNonNull(chunkHolder);
@ -1194,7 +1194,7 @@ index daa6f460d6a1006f91ea5fe63ce86625796801f4..f05c909f65240d3a9a71ac620c395d1e
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) either.left().orElse(null);
if (chunk != null) addTicket(x, z); // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 7a64562326cc462c448245a28fdbcce08fe30310..c4f26fc66554c70ad4ca97737a1d1d0a04559ff0 100644
index 7d42e60ec26f3617bb23c12f415b13e5913603fc..791889e540f03681e6432305772d30eca907716e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1028,6 +1028,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

View File

@ -54,10 +54,10 @@ index ece4cd0de061969d4d2f07560e6cf38e631098b3..90f65fdcc4acf6762c67a5cb3023d249
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index dc000f7ecefdd5013c91cf37db4a15e54e889b24..68038cc68a8abda416a0364dc87535dfc54cd8a1 100644
index 349c311e70758d99ebb4c61ad509a3a975fda04b..82ebf79bdcae552d6e4f5dc4b4c85da26eda356c 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -706,7 +706,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -712,7 +712,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return either.mapLeft((list) -> {
return (LevelChunk) list.get(list.size() / 2);
});
@ -66,7 +66,7 @@ index dc000f7ecefdd5013c91cf37db4a15e54e889b24..68038cc68a8abda416a0364dc87535df
}
@Nullable
@@ -1112,6 +1112,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1118,6 +1118,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return "chunkGenerate " + requiredStatus.getName();
});
Executor executor = (runnable) -> {

View File

@ -10,10 +10,10 @@ schedules. Effectively, use the callback executor as a tool of
finding issues rather than hiding these issues.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 68038cc68a8abda416a0364dc87535dfc54cd8a1..4cdab0f5667c2dd183a07194736506997320b3ce 100644
index 82ebf79bdcae552d6e4f5dc4b4c85da26eda356c..c0f0f952c5dcd43435e6deae0566757ed6290e80 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -167,17 +167,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -168,17 +168,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {

View File

@ -10,10 +10,10 @@ chunk future to complete. We can simply schedule to the immediate
executor to get this effect, rather than the main mailbox.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 4cdab0f5667c2dd183a07194736506997320b3ce..80c83eaabddb3f6fd13322d4aca2eb74a9c19e34 100644
index c0f0f952c5dcd43435e6deae0566757ed6290e80..511ff04a2609de514d98869934a57cbda10b9633 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1325,9 +1325,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1331,9 +1331,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return chunk;
});

View File

@ -8,10 +8,10 @@ Sync loading the chunk at this stage would cause it to load
older data, as well as screwing our region state.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 80c83eaabddb3f6fd13322d4aca2eb74a9c19e34..6212d3203a13ccedbc67a7d2b8bde6af3f5c744a 100644
index 511ff04a2609de514d98869934a57cbda10b9633..753fd5d172c782b6ab9e90aa7c01ed860f8dc3a9 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -316,6 +316,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -317,6 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end
@ -19,7 +19,7 @@ index 80c83eaabddb3f6fd13322d4aca2eb74a9c19e34..6212d3203a13ccedbc67a7d2b8bde6af
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -722,6 +723,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -728,6 +729,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@Nullable
ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) {
@ -27,7 +27,7 @@ index 80c83eaabddb3f6fd13322d4aca2eb74a9c19e34..6212d3203a13ccedbc67a7d2b8bde6af
if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) {
return holder;
} else {
@@ -925,6 +927,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -931,6 +933,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (completablefuture1 != completablefuture) {
this.scheduleUnload(pos, holder);
} else {
@ -40,7 +40,7 @@ index 80c83eaabddb3f6fd13322d4aca2eb74a9c19e34..6212d3203a13ccedbc67a7d2b8bde6af
// Paper start
boolean removed;
if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) {
@@ -962,6 +970,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -968,6 +976,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
}
} // Paper end

View File

@ -70,10 +70,10 @@ index b75b3c4d274252a3a5c53059b9702728eeada389..8bea90cb57f38f33e8b3162e24e35399
int i = 0;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 6212d3203a13ccedbc67a7d2b8bde6af3f5c744a..539c18cf9d86508c738476568334effb29df8b97 100644
index 753fd5d172c782b6ab9e90aa7c01ed860f8dc3a9..bb8478d9a216ec53f650b887508638965f371d47 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -162,6 +162,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -163,6 +163,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final Queue<Runnable> unloadQueue;
int viewDistance;
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper

View File

@ -9,7 +9,7 @@ the function. I saw approximately 1/3rd of the function
on the copy.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 268374eccbccfc45257567f89de25ac83a6416fe..6417aaec8cf219bdfd1f6b2714c7bbadb3d21b36 100644
index 008bb8896657892fcaf64e134684cc49e62f23f6..a538473f4a75791c7c657f9f1e3ddf96042ab071 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -480,7 +480,7 @@ public class PaperCommand extends Command {
@ -35,10 +35,10 @@ index 90ebe2ecd1566acd22e69a134090eb3bd3a8e485..48ec2f7a3813f8ce2baf32667a09f377
List<ChunkHolder> allChunks = new ArrayList<>(visibleChunks.values());
List<ServerPlayer> players = world.players;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f553814a1804a 100644
index bb8478d9a216ec53f650b887508638965f371d47..a04a52b5e154d55a7b1d35f0094bbac055612054 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -125,9 +125,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -126,9 +126,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private static final int MIN_VIEW_DISTANCE = 3;
public static final int MAX_VIEW_DISTANCE = 33;
public static final int MAX_CHUNK_DISTANCE = 33 + ChunkStatus.maxDistance();
@ -52,7 +52,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
private final Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads;
public final LongSet entitiesInLevel;
public final ServerLevel level;
@@ -320,7 +322,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -321,7 +323,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
@ -61,7 +61,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
this.pendingUnloads = new Long2ObjectLinkedOpenHashMap();
this.entitiesInLevel = new LongOpenHashSet();
this.toDrop = new LongOpenHashSet();
@@ -556,12 +558,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -562,12 +564,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@Nullable
public ChunkHolder getUpdatingChunkIfPresent(long pos) {
@ -81,7 +81,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
}
protected IntSupplier getChunkQueueLevel(long pos) {
@@ -701,9 +708,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -707,9 +714,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
};
stringbuilder.append("Updating:").append(System.lineSeparator());
@ -93,7 +93,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
CrashReport crashreport = CrashReport.forThrowable(exception, "Chunk loading");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Chunk loading");
@@ -754,7 +761,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -760,7 +767,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end
}
@ -102,7 +102,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
this.modified = true;
}
@@ -834,7 +841,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -840,7 +847,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
protected void saveAllChunks(boolean flush) {
if (flush) {
@ -111,7 +111,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
MutableBoolean mutableboolean = new MutableBoolean();
do {
@@ -865,7 +872,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -871,7 +878,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
//this.flushWorker(); // Paper - nuke IOWorker
this.level.asyncChunkTaskManager.flush(); // Paper - flush to preserve behavior compat with pre-async behaviour
} else {
@ -120,7 +120,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
}
}
@@ -888,14 +895,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -894,14 +901,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
public boolean hasWork() {
@ -137,7 +137,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
if (playerchunk != null) {
playerchunk.onChunkRemove(); // Paper
@@ -990,7 +997,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -996,7 +1003,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!this.modified) {
return false;
} else {
@ -151,7 +151,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
this.modified = false;
return true;
}
@@ -1490,7 +1502,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1496,7 +1508,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.viewDistance = j;
this.distanceManager.updatePlayerTickets(this.viewDistance + 1);
@ -160,7 +160,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
while (objectiterator.hasNext()) {
ChunkHolder playerchunk = (ChunkHolder) objectiterator.next();
@@ -1533,7 +1545,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1539,7 +1551,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
public int size() {
@ -169,7 +169,7 @@ index 539c18cf9d86508c738476568334effb29df8b97..667ccb6c75010a07fea5c0fa001f5538
}
public DistanceManager getDistanceManager() {
@@ -1541,13 +1553,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1547,13 +1559,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
protected Iterable<ChunkHolder> getChunks() {

View File

@ -7,18 +7,18 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 667ccb6c75010a07fea5c0fa001f553814a1804a..d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e 100644
index a04a52b5e154d55a7b1d35f0094bbac055612054..f77c2eeb6c367df4d72e5908071eb079ee6f0def 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -112,6 +112,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger;
@@ -113,6 +113,7 @@ import org.slf4j.Logger;
import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
import org.bukkit.entity.Player;
// CraftBukkit end
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // Paper
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
@@ -2197,7 +2198,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -2203,7 +2204,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity;
private final int range;
SectionPos lastSectionPos;

View File

@ -39,10 +39,10 @@ index 8bea90cb57f38f33e8b3162e24e353993a98ebbf..5b4c3ca92dffff876af18db106310cb1
// Paper end - optimise anyPlayerCloseEnoughForSpawning
long lastAutoSaveTime; // Paper - incremental autosave
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e..1c5137be8c0935ae371d0b9e6a8f3d8bccd85d31 100644
index f77c2eeb6c367df4d72e5908071eb079ee6f0def..17b6c6ee8c2754e1f98badebf506390c0bb7ce87 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -167,6 +167,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -168,6 +168,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper
public final ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new ReferenceOpenHashSet<>();
@ -56,7 +56,7 @@ index d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e..1c5137be8c0935ae371d0b9e6a8f3d8b
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
@@ -244,6 +251,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -245,6 +252,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end - use distance map to optimise entity tracker
// Note: players need to be explicitly added to distance maps before they can be updated
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -64,7 +64,7 @@ index d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e..1c5137be8c0935ae371d0b9e6a8f3d8b
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.add(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -262,6 +270,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -263,6 +271,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player);
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -72,7 +72,7 @@ index d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e..1c5137be8c0935ae371d0b9e6a8f3d8b
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.remove(player);
@@ -282,6 +291,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -283,6 +292,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end - use distance map to optimise entity tracker
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -80,7 +80,7 @@ index d2227b40aa6a5e49e30c1f33e407d8f25cf2be4e..1c5137be8c0935ae371d0b9e6a8f3d8b
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.update(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -451,6 +461,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -457,6 +467,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
});
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning

View File

@ -8,10 +8,10 @@ Instead, only iterate over navigators in the current region that are
eligible for repathing.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1c5137be8c0935ae371d0b9e6a8f3d8bccd85d31..8939d15bd413a2b743303d137fc797be6d97b9e8 100644
index 17b6c6ee8c2754e1f98badebf506390c0bb7ce87..6671caad52c3a5943334e613b836026c416183b4 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -304,15 +304,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -305,15 +305,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final io.papermc.paper.chunk.SingleThreadChunkRegionManager dataRegionManager;
public static final class DataRegionData implements io.papermc.paper.chunk.SingleThreadChunkRegionManager.RegionData {
@ -93,7 +93,7 @@ index 1c5137be8c0935ae371d0b9e6a8f3d8bccd85d31..8939d15bd413a2b743303d137fc797be
}
@Override
@@ -322,6 +388,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -323,6 +389,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final DataRegionSectionData sectionData = (DataRegionSectionData)section.sectionData;
final DataRegionData oldRegionData = oldRegion == null ? null : (DataRegionData)oldRegion.regionData;
final DataRegionData newRegionData = (DataRegionData)newRegion.regionData;

View File

@ -12,10 +12,10 @@ time to save, as flush saving performs a full flush at
the end anyways.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8939d15bd413a2b743303d137fc797be6d97b9e8..a0318ed330d3dc5d98169d076d9eb94b485bba52 100644
index 6671caad52c3a5943334e613b836026c416183b4..595d414f633e3183147fb4b137a149e948dab332 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -943,6 +943,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -949,6 +949,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end
protected void saveAllChunks(boolean flush) {
@ -32,7 +32,7 @@ index 8939d15bd413a2b743303d137fc797be6d97b9e8..a0318ed330d3dc5d98169d076d9eb94b
if (flush) {
List<ChunkHolder> list = (List) this.updatingChunks.getVisibleValuesCopy().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper
MutableBoolean mutableboolean = new MutableBoolean();
@@ -965,6 +975,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -971,6 +981,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}).filter((ichunkaccess) -> {
return ichunkaccess instanceof ImposterProtoChunk || ichunkaccess instanceof LevelChunk;
}).filter(this::save).forEach((ichunkaccess) -> {

View File

@ -4440,10 +4440,10 @@ index 5b4c3ca92dffff876af18db106310cb14e8612b1..5482be03a667939ff009b6810d5cc90c
private final DebugBuffer<ChunkHolder.ChunkSaveDebug> chunkToSaveHistory;
public int oldTicketLevel;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index a0318ed330d3dc5d98169d076d9eb94b485bba52..169e2514c5d6942fe28f0deb84540bd4a50f0ece 100644
index 595d414f633e3183147fb4b137a149e948dab332..457cd717d6fce598d4cfc41ea59af601ce2c0a85 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -135,7 +135,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -136,7 +136,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final LongSet entitiesInLevel;
public final ServerLevel level;
private final ThreadedLevelLightEngine lightEngine;

View File

@ -10,10 +10,10 @@ This patch also prevents the saving/unloading of POI data when
world saving is disabled.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 169e2514c5d6942fe28f0deb84540bd4a50f0ece..e25423b46ced54dd6b270d45a3c4502a01b2e227 100644
index 457cd717d6fce598d4cfc41ea59af601ce2c0a85..4f6473398edd9987dfbb6cef79ed1bc93c3dd809 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -863,6 +863,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -869,6 +869,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end
}
@ -21,7 +21,7 @@ index 169e2514c5d6942fe28f0deb84540bd4a50f0ece..e25423b46ced54dd6b270d45a3c4502a
this.updatingChunks.queueUpdate(pos, holder); // Paper - Don't copy
this.modified = true;
@@ -1014,7 +1015,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1020,7 +1021,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private void processUnloads(BooleanSupplier shouldKeepTicking) {
LongIterator longiterator = this.toDrop.iterator();
@ -30,7 +30,7 @@ index 169e2514c5d6942fe28f0deb84540bd4a50f0ece..e25423b46ced54dd6b270d45a3c4502a
long j = longiterator.nextLong();
ChunkHolder playerchunk = this.updatingChunks.queueRemove(j); // Paper - Don't copy
@@ -1062,6 +1063,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1068,6 +1069,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
}
// Paper end
@ -38,7 +38,7 @@ index 169e2514c5d6942fe28f0deb84540bd4a50f0ece..e25423b46ced54dd6b270d45a3c4502a
if (ichunkaccess instanceof LevelChunk) {
((LevelChunk) ichunkaccess).setLoaded(false);
}
@@ -1091,6 +1093,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1097,6 +1099,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
for (int index = 0, len = this.regionManagers.size(); index < len; ++index) {
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
}
@ -46,7 +46,7 @@ index 169e2514c5d6942fe28f0deb84540bd4a50f0ece..e25423b46ced54dd6b270d45a3c4502a
} // Paper end
} finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks
@@ -1166,6 +1169,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1172,6 +1175,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
this.poiManager.loadInData(pos, chunkHolder.poiData);
chunkHolder.tasks.forEach(Runnable::run);

View File

@ -1369,10 +1369,10 @@ index 5482be03a667939ff009b6810d5cc90c8601e983..11cd31691307749e925930c4b6e10e3f
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getOrScheduleFuture(ChunkStatus targetStatus, ChunkMap chunkStorage) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c6042effd 100644
index 4f6473398edd9987dfbb6cef79ed1bc93c3dd809..d98c489a58c8c2e657a8879b991aa57ef78f5015 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -220,6 +220,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -221,6 +221,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap; // this map is absent from updateMaps since it's controlled at the start of the chunkproviderserver tick
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -1380,7 +1380,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
// Paper start - use distance map to optimise tracker
public static boolean isLegacyTrackingEntity(Entity entity) {
return entity.isLegacyTrackingEntity;
@@ -239,6 +240,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -240,6 +241,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end - use distance map to optimise tracker
void addPlayerToDistanceMaps(ServerPlayer player) {
@ -1388,7 +1388,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Paper start - use distance map to optimise entity tracker
@@ -246,7 +248,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -247,7 +249,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
int trackRange = this.entityTrackerTrackRanges[i];
@ -1397,7 +1397,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
// Paper end - use distance map to optimise entity tracker
// Note: players need to be explicitly added to distance maps before they can be updated
@@ -276,6 +278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -277,6 +279,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobDistanceMap.remove(player);
}
// Paper end - per player mob spawning
@ -1405,7 +1405,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
void updateMaps(ServerPlayer player) {
@@ -287,7 +290,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -288,7 +291,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
int trackRange = this.entityTrackerTrackRanges[i];
@ -1414,7 +1414,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
// Paper end - use distance map to optimise entity tracker
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@@ -297,6 +300,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -298,6 +301,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobDistanceMap.update(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
}
// Paper end - per player mob spawning
@ -1422,7 +1422,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
// Paper end
// Paper start
@@ -1446,11 +1450,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1452,11 +1456,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
completablefuture1.thenAcceptAsync((either) -> {
either.ifLeft((chunk) -> {
this.tickingGenerated.getAndIncrement();
@ -1435,7 +1435,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
});
}, (runnable) -> {
this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
@@ -1619,33 +1619,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1625,33 +1625,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int k = this.viewDistance;
this.viewDistance = j;
@ -1478,7 +1478,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
if (chunk != null) {
this.playerLoadedChunk(player, packet, chunk);
@@ -1676,7 +1667,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1682,7 +1673,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
void dumpChunks(Writer writer) throws IOException {
CsvOutput csvwriter = CsvOutput.builder().addColumn("x").addColumn("z").addColumn("level").addColumn("in_memory").addColumn("status").addColumn("full_status").addColumn("accessible_ready").addColumn("ticking_ready").addColumn("entity_ticking_ready").addColumn("ticket").addColumn("spawning").addColumn("block_entity_count").addColumn("ticking_ticket").addColumn("ticking_level").addColumn("block_ticks").addColumn("fluid_ticks").build(writer);
@ -1487,7 +1487,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
ObjectBidirectionalIterator objectbidirectionaliterator = this.updatingChunks.getVisibleMap().clone().long2ObjectEntrySet().fastIterator(); // Paper
while (objectbidirectionaliterator.hasNext()) {
@@ -1692,7 +1683,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1698,7 +1689,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// CraftBukkit - decompile error
csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(ChunkAccess::getStatus).orElse(null), optional1.map(LevelChunk::getFullStatus).orElse(null), ChunkMap.printFuture(playerchunk.getFullChunkFuture()), ChunkMap.printFuture(playerchunk.getTickingChunkFuture()), ChunkMap.printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
return chunk.getBlockEntities().size();
@ -1496,7 +1496,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
return chunk.getBlockTicks().count();
}).orElse(0), optional1.map((chunk) -> {
return chunk.getFluidTicks().count();
@@ -1926,15 +1917,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1932,15 +1923,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.removePlayerFromDistanceMaps(player); // Paper - distance maps
}
@ -1513,7 +1513,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
@@ -1942,7 +1925,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1948,7 +1931,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
SectionPos sectionposition = SectionPos.of((EntityAccess) player);
player.setLastSectionPos(sectionposition);
@ -1522,7 +1522,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
return sectionposition;
}
@@ -1987,65 +1970,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1993,65 +1976,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int k1;
int l1;
@ -1610,7 +1610,7 @@ index e25423b46ced54dd6b270d45a3c4502a01b2e227..a78cc85ba2acca982097317d56e7074c
}
public void addEntity(Entity entity) {
@@ -2414,7 +2372,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -2420,7 +2378,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double vec3d_dx = player.getX() - this.entity.getX();
double vec3d_dz = player.getZ() - this.entity.getZ();
// Paper end - remove allocation of Vec3D here

@ -1 +1 @@
Subproject commit b2557f6acd3a2b065643f1c58a411a20c1eef842
Subproject commit cc7edd6bc52f405818c8b995e576cfdcb537d88b