clean up prepareTickingChunk diff

This commit is contained in:
Jason Penilla 2022-03-02 11:24:32 -07:00
parent 12d89fe5ae
commit 90788a556c
No known key found for this signature in database
GPG Key ID: 0E75A301420E48F8
10 changed files with 42 additions and 77 deletions

View File

@ -8,7 +8,7 @@ See: https://gist.github.com/aikar/dd22bbd2a3d78a2fd3d92e95e9f28dc6
as part of post processing a chunk, we can call ChunkConverter. as part of post processing a chunk, we can call ChunkConverter.
ChunkConverter then kicks off major physics updates, and when blocks ChunkConverter then kicks off major physics updates, and when blocks
that have connections across chunk boundries occur, a recursive risk that have connections across chunk boundaries occur, a recursive risk
can occur where A updates a block that triggers a physics request. can occur where A updates a block that triggers a physics request.
That physics request may trigger a chunk request, that then enqueues That physics request may trigger a chunk request, that then enqueues
@ -21,42 +21,11 @@ will be unable to proceed.
We delay post processing of Chunk.A() 1 "pass" by re stuffing it back into We delay post processing of Chunk.A() 1 "pass" by re stuffing it back into
the executor so that the mailbox ChunkQueue is now considered empty. the executor so that the mailbox ChunkQueue is now considered empty.
This successfully fixed a reoccurring and highly reproduceable crash This successfully fixed a reoccurring and highly reproducible crash
for heightmaps. for heightmaps.
TODO FOR LEAF: 1.18.2 changed this
OLD
CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
return either.flatMap((list) -> {
LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
chunk.postProcessGeneration();
this.level.startTickingChunk(chunk);
return Either.left(chunk);
});
}, (runnable) -> {
this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
});
NEW
CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
return either.mapLeft((list) -> {
return (LevelChunk) list.get(list.size() / 2);
});
}, (runnable) -> {
this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
}).thenApplyAsync((either) -> {
return either.ifLeft((chunk) -> {
chunk.postProcessGeneration();
this.level.startTickingChunk(chunk);
});
}, this.mainThreadExecutor);
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 7e3f7b69fc7a608dd82b471d832cc401a77f0738..d251e07eec07f8f822af1f8713e46aebe54b4890 100644 index 7e3f7b69fc7a608dd82b471d832cc401a77f0738..95feb9e316d4d1115c7dad5873979708f8d647d9 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
@@ -178,6 +178,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -178,6 +178,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -67,30 +36,26 @@ index 7e3f7b69fc7a608dd82b471d832cc401a77f0738..d251e07eec07f8f822af1f8713e46aeb
// 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<>();
@@ -1008,17 +1009,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1009,16 +1010,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return ChunkStatus.FULL;
}); });
CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> { CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
- return either.mapLeft((list) -> { return either.mapLeft((list) -> {
- return (LevelChunk) list.get(list.size() / 2); - return (LevelChunk) list.get(list.size() / 2);
- }); - });
- }, (runnable) -> { - }, (runnable) -> {
- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable)); - this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
- }).thenApplyAsync((either) -> { - }).thenApplyAsync((either) -> {
- return either.ifLeft((chunk) -> { - return either.ifLeft((chunk) -> {
+ // Paper start + // Paper start - revert 1.18.2 diff
+ return either.flatMap((list) -> { + final LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
+ LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
chunk.postProcessGeneration(); chunk.postProcessGeneration();
this.level.startTickingChunk(chunk); this.level.startTickingChunk(chunk);
+ return Either.left(chunk); + return chunk;
+
}); });
- }, this.mainThreadExecutor); - }, this.mainThreadExecutor);
+ }, (runnable) -> { + }, (runnable) -> {
+ this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request. + this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
+ }); + }); // Paper end - revert 1.18.2 diff
+ // Paper end
completablefuture1.thenAcceptAsync((either) -> { completablefuture1.thenAcceptAsync((either) -> {
either.ifLeft((chunk) -> { either.ifLeft((chunk) -> {

View File

@ -28,10 +28,10 @@ receives a deterministic result, and should no longer require 1 tick
delays anymore. delays anymore.
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 d251e07eec07f8f822af1f8713e46aebe54b4890..c11dac1aa504a9e82d883134caa9b4b689501ce1 100644 index 95feb9e316d4d1115c7dad5873979708f8d647d9..da40ae8799de108b1d3913c3c27ed4f9273fb303 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
@@ -1624,6 +1624,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1622,6 +1622,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
.printStackTrace(); .printStackTrace();
return; 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index c11dac1aa504a9e82d883134caa9b4b689501ce1..d5e037385263cb094cbbf15823e38e81acafc7d7 100644 index da40ae8799de108b1d3913c3c27ed4f9273fb303..7f8f242a746d542192bf59fc17e43d3544e5a442 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
@@ -1902,9 +1902,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1900,9 +1900,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void updatePlayer(ServerPlayer player) { public void updatePlayer(ServerPlayer player) {
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
if (player != this.entity) { if (player != this.entity) {

View File

@ -42,7 +42,7 @@ index 674a6492e2eb10cfd29989643eedcea08b2d5218..dff475b327d6edaa4dcb9bc09029237f
// Paper start // Paper 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 d5e037385263cb094cbbf15823e38e81acafc7d7..0959adc5ec64d1939fc212151d5e0df073ebc312 100644 index 7f8f242a746d542192bf59fc17e43d3544e5a442..80018a94c12b7963c87b3960b71d88d8ac50ff09 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
@@ -181,11 +181,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -181,11 +181,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -143,7 +143,7 @@ index d5e037385263cb094cbbf15823e38e81acafc7d7..0959adc5ec64d1939fc212151d5e0df0
this.pendingUnloads.put(j, playerchunk); this.pendingUnloads.put(j, playerchunk);
this.modified = true; this.modified = true;
this.scheduleUnload(j, playerchunk); // Paper - Move up - don't leak chunks this.scheduleUnload(j, playerchunk); // Paper - Move up - don't leak chunks
@@ -1386,43 +1437,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1384,43 +1435,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(pos, false); 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. 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 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2f55952fd 100644 index 80018a94c12b7963c87b3960b71d88d8ac50ff09..2ff9c1f1c41494c282b43eafeb719172f664414b 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
@@ -70,6 +70,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; @@ -70,6 +70,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
@ -126,7 +126,7 @@ index 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2
// 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,
@@ -1560,17 +1638,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1558,17 +1636,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
public void move(ServerPlayer player) { public void move(ServerPlayer player) {
@ -145,7 +145,7 @@ index 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2
int i = SectionPos.blockToSectionCoord(player.getBlockX()); int i = SectionPos.blockToSectionCoord(player.getBlockX());
int j = SectionPos.blockToSectionCoord(player.getBlockZ()); int j = SectionPos.blockToSectionCoord(player.getBlockZ());
@@ -1697,7 +1765,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1695,7 +1763,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 +154,7 @@ index 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2
if (entity instanceof ServerPlayer) { if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity; ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1741,7 +1809,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1739,7 +1807,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 +192,7 @@ index 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2
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();
@@ -1817,23 +1915,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1815,23 +1913,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 +236,7 @@ index 0959adc5ec64d1939fc212151d5e0df073ebc312..1400975fd7debce564f289bf32d14dc2
Iterator iterator; Iterator iterator;
Entity entity1; Entity entity1;
@@ -1909,6 +2015,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1907,6 +2013,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lastSectionPos = SectionPos.of(entity); this.lastSectionPos = SectionPos.of(entity);
} }

View File

@ -165,7 +165,7 @@ index dff475b327d6edaa4dcb9bc09029237f8f659846..05d2790b80a6d2e1dc6b8d2375f783be
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 1400975fd7debce564f289bf32d14dc2f55952fd..644ab527da5107c7cbfc037a143b1afe54efed7b 100644 index 2ff9c1f1c41494c282b43eafeb719172f664414b..85a05c9e59ae1909e6d4ce7a2e45b16366a1b7dc 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
@@ -104,6 +104,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana @@ -104,6 +104,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana
@ -264,7 +264,7 @@ index 1400975fd7debce564f289bf32d14dc2f55952fd..644ab527da5107c7cbfc037a143b1afe
this.lightEngine.updateChunkStatus(ichunkaccess.getPos()); this.lightEngine.updateChunkStatus(ichunkaccess.getPos());
this.lightEngine.tryScheduleUpdate(); this.lightEngine.tryScheduleUpdate();
@@ -1248,6 +1302,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1246,6 +1300,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
asyncSaveData, chunk); asyncSaveData, chunk);
chunk.setUnsaved(false); chunk.setUnsaved(false);
@ -272,7 +272,7 @@ index 1400975fd7debce564f289bf32d14dc2f55952fd..644ab527da5107c7cbfc037a143b1afe
} }
// Paper end // Paper end
@@ -1257,6 +1312,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1255,6 +1310,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (!chunk.isUnsaved()) { if (!chunk.isUnsaved()) {
return false; return false;
} else { } else {

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. 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 fcfb7df39457a539fea4c6b6af17d9d05e6ce812..74623b0f56e64afadb87cb6924159c0f9b79a56c 100644 index edb35a483ae44073d560df1fe949aad60bf3d39d..fdfac353fe9cf8509a08b5157ed0762c3a12f3e3 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
@@ -1316,9 +1316,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1314,9 +1314,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return chunk; return chunk;
}); });

View File

@ -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 7aa89874aeb53755fc75f56614568f31110af42a..50a89a1f485611249a1b393ae75b4ff6b9534402 100644 index 9b2c5fe2389c6baa239de4f7b479d9ca273e59cf..c19395ab43b956787bf0e59ae242ff3a53d4ca46 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
@@ -123,9 +123,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -123,9 +123,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -152,7 +152,7 @@ index 7aa89874aeb53755fc75f56614568f31110af42a..50a89a1f485611249a1b393ae75b4ff6
this.modified = false; this.modified = false;
return true; return true;
} }
@@ -1481,7 +1493,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1479,7 +1491,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);
@ -161,7 +161,7 @@ index 7aa89874aeb53755fc75f56614568f31110af42a..50a89a1f485611249a1b393ae75b4ff6
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
ChunkHolder playerchunk = (ChunkHolder) objectiterator.next(); ChunkHolder playerchunk = (ChunkHolder) objectiterator.next();
@@ -1524,7 +1536,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1522,7 +1534,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
public int size() { public int size() {
@ -170,7 +170,7 @@ index 7aa89874aeb53755fc75f56614568f31110af42a..50a89a1f485611249a1b393ae75b4ff6
} }
public DistanceManager getDistanceManager() { public DistanceManager getDistanceManager() {
@@ -1532,13 +1544,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1530,13 +1542,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
protected Iterable<ChunkHolder> getChunks() { protected Iterable<ChunkHolder> getChunks() {

View File

@ -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 50a89a1f485611249a1b393ae75b4ff6b9534402..01cb03ab0839aa7e2b9c54226b557306e4115348 100644 index c19395ab43b956787bf0e59ae242ff3a53d4ca46..af9b1fe737ab430861b4d0de33eec1325964c3a5 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
@@ -110,6 +110,7 @@ import org.apache.commons.lang3.mutable.MutableObject; @@ -110,6 +110,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
@ -18,7 +18,7 @@ index 50a89a1f485611249a1b393ae75b4ff6b9534402..01cb03ab0839aa7e2b9c54226b557306
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
@@ -2171,7 +2172,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -2169,7 +2170,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;

View File

@ -1381,7 +1381,7 @@ index 36b6e7295cf7484675c8c2b9624c1f6fea7aed1d..38db3905f47fefb5c958fa24aef2313e
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getOrScheduleFuture(ChunkStatus targetStatus, ChunkMap chunkStorage) { 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc19f707f1 100644 index a29b97f941eadb1ede5db805d32f2917469cccb9..edc6235288f0843608dae4552e05915e4067cbf2 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
@@ -217,6 +217,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -217,6 +217,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -1434,7 +1434,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
} }
// Paper end // Paper end
// Paper start // Paper start
@@ -1437,11 +1441,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1435,11 +1439,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
completablefuture1.thenAcceptAsync((either) -> { completablefuture1.thenAcceptAsync((either) -> {
either.ifLeft((chunk) -> { either.ifLeft((chunk) -> {
this.tickingGenerated.getAndIncrement(); this.tickingGenerated.getAndIncrement();
@ -1447,7 +1447,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
}); });
}, (runnable) -> { }, (runnable) -> {
this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable)); this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
@@ -1610,33 +1610,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1608,33 +1608,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int k = this.viewDistance; int k = this.viewDistance;
this.viewDistance = j; this.viewDistance = j;
@ -1490,7 +1490,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
if (chunk != null) { if (chunk != null) {
this.playerLoadedChunk(player, packet, chunk); this.playerLoadedChunk(player, packet, chunk);
@@ -1667,7 +1658,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1665,7 +1656,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
void dumpChunks(Writer writer) throws IOException { 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); 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);
@ -1499,7 +1499,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
ObjectBidirectionalIterator objectbidirectionaliterator = this.updatingChunks.getVisibleMap().clone().long2ObjectEntrySet().fastIterator(); // Paper ObjectBidirectionalIterator objectbidirectionaliterator = this.updatingChunks.getVisibleMap().clone().long2ObjectEntrySet().fastIterator(); // Paper
while (objectbidirectionaliterator.hasNext()) { while (objectbidirectionaliterator.hasNext()) {
@@ -1683,7 +1674,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1681,7 +1672,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// CraftBukkit - decompile error // 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) -> { 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(); return chunk.getBlockEntities().size();
@ -1508,7 +1508,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
return chunk.getBlockTicks().count(); return chunk.getBlockTicks().count();
}).orElse(0), optional1.map((chunk) -> { }).orElse(0), optional1.map((chunk) -> {
return chunk.getFluidTicks().count(); return chunk.getFluidTicks().count();
@@ -1900,15 +1891,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1898,15 +1889,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.removePlayerFromDistanceMaps(player); // Paper - distance maps this.removePlayerFromDistanceMaps(player); // Paper - distance maps
} }
@ -1525,7 +1525,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
} }
@@ -1916,7 +1899,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1914,7 +1897,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
SectionPos sectionposition = SectionPos.of((Entity) player); SectionPos sectionposition = SectionPos.of((Entity) player);
player.setLastSectionPos(sectionposition); player.setLastSectionPos(sectionposition);
@ -1534,7 +1534,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
return sectionposition; return sectionposition;
} }
@@ -1961,65 +1944,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1959,65 +1942,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int k1; int k1;
int l1; int l1;
@ -1622,7 +1622,7 @@ index 81442caecba8c85ab5af96d712841615b7b7a5dd..42056c7a506a7edfe8a5feabacece5bc
} }
public void addEntity(Entity entity) { public void addEntity(Entity entity) {
@@ -2388,7 +2346,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -2386,7 +2344,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double vec3d_dx = player.getX() - this.entity.getX(); double vec3d_dx = player.getX() - this.entity.getX();
double vec3d_dz = player.getZ() - this.entity.getZ(); double vec3d_dz = player.getZ() - this.entity.getZ();
// Paper end - remove allocation of Vec3D here // Paper end - remove allocation of Vec3D here