3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Remove wrong update call in distance map add method

Dieser Commit ist enthalten in:
Jason Penilla 2021-12-31 13:59:34 -08:00
Ursprung 64f9225c94
Commit c40e04e9e7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0E75A301420E48F8
13 geänderte Dateien mit 75 neuen und 80 gelöschten Zeilen

Datei anzeigen

@ -37,10 +37,10 @@ index 74d674b2684b0db4aa6c183edc6091d53e9ee882..626bcbc6dd013260c3f8b38a1d14e7ba
// CraftBukkit start // CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 62a8482b73796f2c6b76c0e039cb21e799bc9416..44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4 100644 index 62a8482b73796f2c6b76c0e039cb21e799bc9416..87b612c25f865af4c8da72c761b70094fb89c4cb 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -177,21 +177,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -177,21 +177,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final CallbackExecutor chunkLoadConversionCallbackExecutor = new CallbackExecutor(); // Paper final CallbackExecutor chunkLoadConversionCallbackExecutor = new CallbackExecutor(); // Paper
// Paper start - distance maps // Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@ -60,10 +60,7 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..44dc880042dc16a4146c6d3bb35a8eb7
int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
+ // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
+ this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
+ // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
} }
void removePlayerFromDistanceMaps(ServerPlayer player) { void removePlayerFromDistanceMaps(ServerPlayer player) {
@ -82,7 +79,7 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..44dc880042dc16a4146c6d3bb35a8eb7
} }
// Paper end // Paper end
// Paper start // Paper start
@@ -266,6 +285,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -266,6 +282,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager); this.regionManagers.add(this.dataRegionManager);
// Paper end // Paper end
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
@ -121,7 +118,7 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..44dc880042dc16a4146c6d3bb35a8eb7
} }
protected ChunkGenerator generator() { protected ChunkGenerator generator() {
@@ -466,6 +517,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -466,6 +514,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} else { } else {
if (holder != null) { if (holder != null) {
holder.setTicketLevel(level); holder.setTicketLevel(level);
@ -129,7 +126,7 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..44dc880042dc16a4146c6d3bb35a8eb7
} }
if (holder != null) { if (holder != null) {
@@ -1310,43 +1362,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1310,43 +1359,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(pos, false); return this.anyPlayerCloseEnoughForSpawning(pos, false);
} }

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2e71e7f1d 100644 index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc845bbacb1 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -67,6 +67,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; @@ -67,6 +67,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
@ -17,7 +17,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.util.CsvOutput; import net.minecraft.util.CsvOutput;
@@ -188,10 +189,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -188,15 +189,45 @@ 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 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; public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -51,9 +51,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
+ } + }
+ // Paper end - use distance map to optimise entity tracker + // Paper end - use distance map to optimise entity tracker
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
@@ -200,6 +226,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
void removePlayerFromDistanceMaps(ServerPlayer player) { void removePlayerFromDistanceMaps(ServerPlayer player) {
@ -65,7 +63,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
this.playerMobSpawnMap.remove(player); this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player); this.playerChunkTickRangeMap.remove(player);
@@ -210,6 +241,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -207,6 +238,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
@ -80,7 +78,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
} }
// Paper end // Paper end
@@ -285,6 +324,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -282,6 +321,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager); this.regionManagers.add(this.dataRegionManager);
// Paper end // Paper end
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
@ -126,7 +124,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets, 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, (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
@@ -1485,17 +1563,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1482,17 +1560,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
public void move(ServerPlayer player) { public void move(ServerPlayer player) {
@ -145,7 +143,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
int i = SectionPos.blockToSectionCoord(player.getBlockX()); int i = SectionPos.blockToSectionCoord(player.getBlockX());
int j = SectionPos.blockToSectionCoord(player.getBlockZ()); int j = SectionPos.blockToSectionCoord(player.getBlockZ());
@@ -1622,7 +1690,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1619,7 +1687,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker); this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
@ -154,7 +152,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
if (entity instanceof ServerPlayer) { if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity; ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1666,7 +1734,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1663,7 +1731,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = null; // Paper - We're no longer tracked entity.tracker = null; // Paper - We're no longer tracked
} }
@ -192,7 +190,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
List<ServerPlayer> list = Lists.newArrayList(); List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players(); List<ServerPlayer> list1 = this.level.players();
ObjectIterator objectiterator = this.entityMap.values().iterator(); ObjectIterator objectiterator = this.entityMap.values().iterator();
@@ -1742,23 +1840,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1739,23 +1837,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos()); DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos());
List<Entity> list = Lists.newArrayList(); List<Entity> list = Lists.newArrayList();
List<Entity> list1 = Lists.newArrayList(); List<Entity> list1 = Lists.newArrayList();
@ -236,7 +234,7 @@ index 44dc880042dc16a4146c6d3bb35a8eb7b28fd3a4..847c4705f88b999976c9a99519939eb2
Iterator iterator; Iterator iterator;
Entity entity1; Entity entity1;
@@ -1834,6 +1940,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1831,6 +1937,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lastSectionPos = SectionPos.of(entity); this.lastSectionPos = SectionPos.of(entity);
} }

Datei anzeigen

@ -165,7 +165,7 @@ index 626bcbc6dd013260c3f8b38a1d14e7ba35dc1e01..9e96b0465717bfa761289c255fd8d2f1
for (int i = 0; i < this.futures.length(); ++i) { for (int i = 0; i < this.futures.length(); ++i) {
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3e6596d57 100644 index 2534cae6f1b369843808aac91931bdc845bbacb1..74187951dc906e72904788ff0b42adc263b790bc 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -101,6 +101,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana @@ -101,6 +101,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana
@ -176,7 +176,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3
import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.lang3.mutable.MutableObject; import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@@ -639,6 +640,64 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -636,6 +637,64 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
@ -241,7 +241,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3
protected void saveAllChunks(boolean flush) { protected void saveAllChunks(boolean flush) {
if (flush) { if (flush) {
List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList());
@@ -732,13 +791,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -729,13 +788,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
int l = 0; int l = 0;
@ -256,7 +256,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3
} }
@@ -776,6 +829,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -773,6 +826,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.level.unload(chunk); this.level.unload(chunk);
} }
@ -264,7 +264,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3
this.lightEngine.updateChunkStatus(ichunkaccess.getPos()); this.lightEngine.updateChunkStatus(ichunkaccess.getPos());
this.lightEngine.tryScheduleUpdate(); this.lightEngine.tryScheduleUpdate();
@@ -1173,6 +1227,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1170,6 +1224,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
asyncSaveData, chunk); asyncSaveData, chunk);
chunk.setUnsaved(false); chunk.setUnsaved(false);
@ -272,7 +272,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3
} }
// Paper end // Paper end
@@ -1182,6 +1237,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1179,6 +1234,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!chunk.isUnsaved()) { if (!chunk.isUnsaved()) {
return false; return false;
} else { } else {

Datei anzeigen

@ -360,7 +360,7 @@ index 9e96b0465717bfa761289c255fd8d2f1df1be3d8..87271552aa85626f22f7f8569c8fb48f
return this.isEntityTickingReady; 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55024efa76 100644 index 74187951dc906e72904788ff0b42adc263b790bc..0d01fc498d09c5e11d8d173ca98d892cb8adc4b8 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -128,6 +128,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -128,6 +128,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -371,7 +371,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
public ChunkGenerator generator; public ChunkGenerator generator;
public final Supplier<DimensionDataStorage> overworldDataStorage; public final Supplier<DimensionDataStorage> overworldDataStorage;
private final PoiManager poiManager; private final PoiManager poiManager;
@@ -302,6 +303,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -299,6 +300,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.level = world; this.level = world;
this.generator = chunkGenerator; this.generator = chunkGenerator;
this.mainThreadExecutor = mainThreadExecutor; this.mainThreadExecutor = mainThreadExecutor;
@ -387,7 +387,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
ProcessorMailbox<Runnable> threadedmailbox = ProcessorMailbox.create(executor, "worldgen"); ProcessorMailbox<Runnable> threadedmailbox = ProcessorMailbox.create(executor, "worldgen");
Objects.requireNonNull(mainThreadExecutor); Objects.requireNonNull(mainThreadExecutor);
@@ -413,6 +423,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -410,6 +420,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}); });
} }
@ -425,7 +425,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
// Paper start // Paper start
public void updatePlayerMobTypeMap(Entity entity) { public void updatePlayerMobTypeMap(Entity entity) {
if (!this.level.paperConfig.perPlayerMobSpawns) { if (!this.level.paperConfig.perPlayerMobSpawns) {
@@ -517,6 +558,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -514,6 +555,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
List<ChunkHolder> list1 = new ArrayList(); List<ChunkHolder> list1 = new ArrayList();
int j = centerChunk.x; int j = centerChunk.x;
int k = centerChunk.z; int k = centerChunk.z;
@ -433,7 +433,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
for (int l = -margin; l <= margin; ++l) { for (int l = -margin; l <= margin; ++l) {
for (int i1 = -margin; i1 <= margin; ++i1) { for (int i1 = -margin; i1 <= margin; ++i1) {
@@ -535,6 +577,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -532,6 +574,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
ChunkStatus chunkstatus = (ChunkStatus) distanceToStatus.apply(j1); ChunkStatus chunkstatus = (ChunkStatus) distanceToStatus.apply(j1);
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = playerchunk.getOrScheduleFuture(chunkstatus, this); CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = playerchunk.getOrScheduleFuture(chunkstatus, this);
@ -448,7 +448,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
list1.add(playerchunk); list1.add(playerchunk);
list.add(completablefuture); list.add(completablefuture);
@@ -869,11 +919,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -866,11 +916,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (requiredStatus == ChunkStatus.EMPTY) { if (requiredStatus == ChunkStatus.EMPTY) {
return this.scheduleChunkLoad(chunkcoordintpair); return this.scheduleChunkLoad(chunkcoordintpair);
} else { } else {
@ -469,7 +469,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
if (optional.isPresent() && ((ChunkAccess) optional.get()).getStatus().isOrAfter(requiredStatus)) { if (optional.isPresent() && ((ChunkAccess) optional.get()).getStatus().isOrAfter(requiredStatus)) {
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = requiredStatus.load(this.level, this.structureManager, this.lightEngine, (ichunkaccess) -> { CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = requiredStatus.load(this.level, this.structureManager, this.lightEngine, (ichunkaccess) -> {
@@ -885,6 +943,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -882,6 +940,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} else { } else {
return this.scheduleChunkGeneration(holder, requiredStatus); return this.scheduleChunkGeneration(holder, requiredStatus);
} }
@ -477,7 +477,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
} }
} }
@@ -941,14 +1000,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -938,14 +997,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}; };
CompletableFuture<CompoundTag> chunkSaveFuture = this.level.asyncChunkTaskManager.getChunkSaveFuture(pos.x, pos.z); CompletableFuture<CompoundTag> chunkSaveFuture = this.level.asyncChunkTaskManager.getChunkSaveFuture(pos.x, pos.z);
@ -507,7 +507,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
return ret; return ret;
// Paper end // Paper end
} }
@@ -1000,7 +1069,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -997,7 +1066,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.releaseLightTicket(chunkcoordintpair); this.releaseLightTicket(chunkcoordintpair);
return CompletableFuture.completedFuture(Either.right(playerchunk_failure)); return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
}); });
@ -519,7 +519,7 @@ index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55
} }
protected void releaseLightTicket(ChunkPos pos) { protected void releaseLightTicket(ChunkPos pos) {
@@ -1084,7 +1156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1081,7 +1153,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
long i = chunkHolder.getPos().toLong(); long i = chunkHolder.getPos().toLong();
Objects.requireNonNull(chunkHolder); Objects.requireNonNull(chunkHolder);

Datei anzeigen

@ -54,10 +54,10 @@ index 87271552aa85626f22f7f8569c8fb48fe4b30bf3..80aae4303e011dad13ce818136f0383e
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) { public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size()); 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d9f1456f5f217655396c4095e1595f55024efa76..71cfc51223e12cdd1030f0e5bb2263d594fa4c3c 100644 index 0d01fc498d09c5e11d8d173ca98d892cb8adc4b8..b44f1dc663dc3c081ec85941a2cd73e522e3c348 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -636,7 +636,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -633,7 +633,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return either.mapLeft((list) -> { return either.mapLeft((list) -> {
return (LevelChunk) list.get(list.size() / 2); return (LevelChunk) list.get(list.size() / 2);
}); });
@ -66,7 +66,7 @@ index d9f1456f5f217655396c4095e1595f55024efa76..71cfc51223e12cdd1030f0e5bb2263d5
} }
@Nullable @Nullable
@@ -1040,6 +1040,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1037,6 +1037,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return "chunkGenerate " + requiredStatus.getName(); return "chunkGenerate " + requiredStatus.getName();
}); });
Executor executor = (runnable) -> { Executor executor = (runnable) -> {

Datei anzeigen

@ -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. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 76f40342098c1cc1ffb855ef41349953f8b94d0f..0090ef1df54c5b438bc4b23d2ed8978575e48dae 100644 index 23aeeea2b05941d8f31c720567532510bea5abb3..4a36952d81b92ed3cf8b5be8cbb6f0353d64a6d7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1253,9 +1253,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1250,9 +1250,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return chunk; return chunk;
}); });

Datei anzeigen

@ -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. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 0090ef1df54c5b438bc4b23d2ed8978575e48dae..e0b445c13bae4205bb33b082dfb0b6b6a4351e6d 100644 index 4a36952d81b92ed3cf8b5be8cbb6f0353d64a6d7..65b58b8a88a72c27bd10387a46dd3822c376ccd3 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -296,6 +296,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -293,6 +293,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end // Paper end
@ -19,7 +19,7 @@ index 0090ef1df54c5b438bc4b23d2ed8978575e48dae..e0b445c13bae4205bb33b082dfb0b6b6
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) { public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, 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); super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
this.visibleChunkMap = this.updatingChunkMap.clone(); this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -652,6 +653,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -649,6 +650,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@Nullable @Nullable
ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) { ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) {
@ -27,7 +27,7 @@ index 0090ef1df54c5b438bc4b23d2ed8978575e48dae..e0b445c13bae4205bb33b082dfb0b6b6
if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) { if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) {
return holder; return holder;
} else { } else {
@@ -864,6 +866,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -861,6 +863,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (completablefuture1 != completablefuture) { if (completablefuture1 != completablefuture) {
this.scheduleUnload(pos, holder); this.scheduleUnload(pos, holder);
} else { } else {
@ -40,7 +40,7 @@ index 0090ef1df54c5b438bc4b23d2ed8978575e48dae..e0b445c13bae4205bb33b082dfb0b6b6
// Paper start // Paper start
boolean removed; boolean removed;
if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) { if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) {
@@ -900,6 +908,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -897,6 +905,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
} }
} // Paper end } // Paper end

Datei anzeigen

@ -35,7 +35,7 @@ index b3516862d796c2d9fcc1c67a6073445403d73088..b61abf227a04b4565c2525e5f469db30
List<ChunkHolder> allChunks = new ArrayList<>(visibleChunks.values()); List<ChunkHolder> allChunks = new ArrayList<>(visibleChunks.values());
List<ServerPlayer> players = world.players; 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc9023f35c12 100644 index 65b58b8a88a72c27bd10387a46dd3822c376ccd3..47f78643d226932093f14b3f536fdb87eeaddb16 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -120,9 +120,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -120,9 +120,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -52,7 +52,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
private final Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads; private final Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads;
public final LongSet entitiesInLevel; public final LongSet entitiesInLevel;
public final ServerLevel level; public final ServerLevel level;
@@ -299,7 +301,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -296,7 +298,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) { public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, 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); super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
@ -61,7 +61,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
this.pendingUnloads = new Long2ObjectLinkedOpenHashMap(); this.pendingUnloads = new Long2ObjectLinkedOpenHashMap();
this.entitiesInLevel = new LongOpenHashSet(); this.entitiesInLevel = new LongOpenHashSet();
this.toDrop = new LongOpenHashSet(); this.toDrop = new LongOpenHashSet();
@@ -516,12 +518,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -513,12 +515,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@Nullable @Nullable
public ChunkHolder getUpdatingChunkIfPresent(long pos) { public ChunkHolder getUpdatingChunkIfPresent(long pos) {
@ -81,7 +81,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
} }
protected IntSupplier getChunkQueueLevel(long pos) { protected IntSupplier getChunkQueueLevel(long pos) {
@@ -683,7 +690,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -680,7 +687,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end // Paper end
} }
@ -90,7 +90,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
this.modified = true; this.modified = true;
} }
@@ -763,7 +770,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -760,7 +767,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
protected void saveAllChunks(boolean flush) { protected void saveAllChunks(boolean flush) {
if (flush) { if (flush) {
@ -99,7 +99,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
MutableBoolean mutableboolean = new MutableBoolean(); MutableBoolean mutableboolean = new MutableBoolean();
do { do {
@@ -794,7 +801,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -791,7 +798,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
//this.flushWorker(); // Paper - nuke IOWorker //this.flushWorker(); // Paper - nuke IOWorker
this.level.asyncChunkTaskManager.flush(); // Paper - flush to preserve behavior compat with pre-async behaviour this.level.asyncChunkTaskManager.flush(); // Paper - flush to preserve behavior compat with pre-async behaviour
} else { } else {
@ -108,7 +108,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
} }
} }
@@ -828,7 +835,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -825,7 +832,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
while (longiterator.hasNext()) { // Spigot while (longiterator.hasNext()) { // Spigot
long j = longiterator.nextLong(); long j = longiterator.nextLong();
longiterator.remove(); // Spigot longiterator.remove(); // Spigot
@ -117,7 +117,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
if (playerchunk != null) { if (playerchunk != null) {
this.pendingUnloads.put(j, playerchunk); this.pendingUnloads.put(j, playerchunk);
@@ -927,7 +934,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -924,7 +931,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!this.modified) { if (!this.modified) {
return false; return false;
} else { } else {
@ -131,7 +131,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
this.modified = false; this.modified = false;
return true; return true;
} }
@@ -1405,7 +1417,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1402,7 +1414,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.viewDistance = j; this.viewDistance = j;
this.distanceManager.updatePlayerTickets(this.viewDistance + 1); this.distanceManager.updatePlayerTickets(this.viewDistance + 1);
@ -140,7 +140,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
ChunkHolder playerchunk = (ChunkHolder) objectiterator.next(); ChunkHolder playerchunk = (ChunkHolder) objectiterator.next();
@@ -1448,7 +1460,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1445,7 +1457,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
public int size() { public int size() {
@ -149,7 +149,7 @@ index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc90
} }
public DistanceManager getDistanceManager() { public DistanceManager getDistanceManager() {
@@ -1456,13 +1468,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1453,13 +1465,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
protected Iterable<ChunkHolder> getChunks() { protected Iterable<ChunkHolder> getChunks() {

Datei anzeigen

@ -7,7 +7,7 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 9c729af97a7658778bd96c121823bc9023f35c12..ad0997ec4e36937e937195d95df701b1954ef885 100644 index 47f78643d226932093f14b3f536fdb87eeaddb16..9b70613762310f50f2c036f3d462b76538d1165f 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -108,6 +108,7 @@ import org.apache.logging.log4j.LogManager; @@ -108,6 +108,7 @@ import org.apache.logging.log4j.LogManager;
@ -18,7 +18,7 @@ index 9c729af97a7658778bd96c121823bc9023f35c12..ad0997ec4e36937e937195d95df701b1
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
@@ -2095,7 +2096,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -2092,7 +2093,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity; final Entity entity;
private final int range; private final int range;
SectionPos lastSectionPos; SectionPos lastSectionPos;

Datei anzeigen

@ -26,7 +26,7 @@ index 1f602d50f3212078490c0092ceefd3b17e0b1532..825fdb0336b0388dbbc54c8da9978190
// Paper end - optimise anyPlayerCloseEnoughForSpawning // Paper end - optimise anyPlayerCloseEnoughForSpawning
long lastAutoSaveTime; // Paper - incremental autosave 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 087eec200cec325edb11f7fbae1a81a216b019d6..86d751738ae82257b527f01b805c30d055ac85c9 100644 index 9b70613762310f50f2c036f3d462b76538d1165f..db739bc7d10db0e27fdeba24165bbf2951b2802b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -159,6 +159,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -159,6 +159,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -43,15 +43,15 @@ index 087eec200cec325edb11f7fbae1a81a216b019d6..86d751738ae82257b527f01b805c30d0
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
public final CallbackExecutor callbackExecutor = new CallbackExecutor(); public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable { public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
@@ -239,6 +246,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -236,6 +243,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper end - use distance map to optimise entity tracker
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Note: players need to be explicitly added to distance maps before they can be updated
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
+ this.playerGeneralAreaMap.add(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn + this.playerGeneralAreaMap.add(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
} }
void removePlayerFromDistanceMaps(ServerPlayer player) { void removePlayerFromDistanceMaps(ServerPlayer player) {
@@ -251,6 +259,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -248,6 +256,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobSpawnMap.remove(player); this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player); this.playerChunkTickRangeMap.remove(player);
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -59,7 +59,7 @@ index 087eec200cec325edb11f7fbae1a81a216b019d6..86d751738ae82257b527f01b805c30d0
} }
void updateMaps(ServerPlayer player) { void updateMaps(ServerPlayer player) {
@@ -266,6 +275,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -263,6 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end - use distance map to optimise entity tracker // Paper end - use distance map to optimise entity tracker
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -67,7 +67,7 @@ index 087eec200cec325edb11f7fbae1a81a216b019d6..86d751738ae82257b527f01b805c30d0
} }
// Paper end // Paper end
// Paper start // Paper start
@@ -421,6 +431,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -418,6 +428,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
}); });
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning

Datei anzeigen

@ -8,10 +8,10 @@ Instead, only iterate over navigators in the current region that are
eligible for repathing. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 86d751738ae82257b527f01b805c30d055ac85c9..7cd99b894914404be9be3a58b1ec83dc08538929 100644 index db739bc7d10db0e27fdeba24165bbf2951b2802b..82f19265435cb4bff4928ce81e0b4682088fac9d 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -283,15 +283,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -280,15 +280,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final io.papermc.paper.chunk.SingleThreadChunkRegionManager dataRegionManager; public final io.papermc.paper.chunk.SingleThreadChunkRegionManager dataRegionManager;
public static final class DataRegionData implements io.papermc.paper.chunk.SingleThreadChunkRegionManager.RegionData { public static final class DataRegionData implements io.papermc.paper.chunk.SingleThreadChunkRegionManager.RegionData {
@ -93,7 +93,7 @@ index 86d751738ae82257b527f01b805c30d055ac85c9..7cd99b894914404be9be3a58b1ec83dc
} }
@Override @Override
@@ -301,6 +367,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -298,6 +364,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final DataRegionSectionData sectionData = (DataRegionSectionData)section.sectionData; final DataRegionSectionData sectionData = (DataRegionSectionData)section.sectionData;
final DataRegionData oldRegionData = oldRegion == null ? null : (DataRegionData)oldRegion.regionData; final DataRegionData oldRegionData = oldRegion == null ? null : (DataRegionData)oldRegion.regionData;
final DataRegionData newRegionData = (DataRegionData)newRegion.regionData; final DataRegionData newRegionData = (DataRegionData)newRegion.regionData;

Datei anzeigen

@ -12,10 +12,10 @@ time to save, as flush saving performs a full flush at
the end anyways. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 7cd99b894914404be9be3a58b1ec83dc08538929..b5ea631f93b9390f82475560cf3e33585d034cd6 100644 index 82f19265435cb4bff4928ce81e0b4682088fac9d..df785c230dde77eb8805872ccb506f882250547f 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -872,6 +872,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -869,6 +869,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end // Paper end
protected void saveAllChunks(boolean flush) { protected void saveAllChunks(boolean flush) {
@ -32,7 +32,7 @@ index 7cd99b894914404be9be3a58b1ec83dc08538929..b5ea631f93b9390f82475560cf3e3358
if (flush) { if (flush) {
List<ChunkHolder> list = (List) this.updatingChunks.getVisibleValuesCopy().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper List<ChunkHolder> list = (List) this.updatingChunks.getVisibleValuesCopy().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper
MutableBoolean mutableboolean = new MutableBoolean(); MutableBoolean mutableboolean = new MutableBoolean();
@@ -894,6 +904,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -891,6 +901,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}).filter((ichunkaccess) -> { }).filter((ichunkaccess) -> {
return ichunkaccess instanceof ImposterProtoChunk || ichunkaccess instanceof LevelChunk; return ichunkaccess instanceof ImposterProtoChunk || ichunkaccess instanceof LevelChunk;
}).filter(this::save).forEach((ichunkaccess) -> { }).filter(this::save).forEach((ichunkaccess) -> {

Datei anzeigen

@ -10,10 +10,10 @@ This patch also prevents the saving/unloading of POI data when
world saving is disabled. 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070a840f3b1 100644 index 478054bde7fdaeed77f56ca4ead9e1740a439ce0..b127949def00b312266b9207264758bf60f5c136 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -792,6 +792,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -789,6 +789,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end // Paper end
} }
@ -21,7 +21,7 @@ index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070
this.updatingChunks.queueUpdate(pos, holder); // Paper - Don't copy this.updatingChunks.queueUpdate(pos, holder); // Paper - Don't copy
this.modified = true; this.modified = true;
@@ -937,7 +938,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -934,7 +935,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
gameprofilerfiller.pop(); gameprofilerfiller.pop();
} }
@ -30,7 +30,7 @@ index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070
private void processUnloads(BooleanSupplier shouldKeepTicking) { private void processUnloads(BooleanSupplier shouldKeepTicking) {
LongIterator longiterator = this.toDrop.iterator(); LongIterator longiterator = this.toDrop.iterator();
@@ -1000,6 +1001,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -997,6 +998,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
} }
// Paper end // Paper end
@ -38,7 +38,7 @@ index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070
if (ichunkaccess instanceof LevelChunk) { if (ichunkaccess instanceof LevelChunk) {
((LevelChunk) ichunkaccess).setLoaded(false); ((LevelChunk) ichunkaccess).setLoaded(false);
} }
@@ -1028,6 +1030,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1025,6 +1027,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
for (int index = 0, len = this.regionManagers.size(); index < len; ++index) { for (int index = 0, len = this.regionManagers.size(); index < len; ++index) {
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
} }
@ -46,7 +46,7 @@ index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070
} // Paper end } // Paper end
} finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks } finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks
@@ -1104,6 +1107,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1101,6 +1104,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
this.poiManager.loadInData(pos, chunkHolder.poiData); this.poiManager.loadInData(pos, chunkHolder.poiData);
chunkHolder.tasks.forEach(Runnable::run); chunkHolder.tasks.forEach(Runnable::run);