diff --git a/patches/server/0003-New-player-chunk-loader-system.patch b/patches/server/0003-New-player-chunk-loader-system.patch index d904e31..60127b9 100644 --- a/patches/server/0003-New-player-chunk-loader-system.patch +++ b/patches/server/0003-New-player-chunk-loader-system.patch @@ -1736,7 +1736,7 @@ index 6efb8b10f17c70b05128039376d254e6beda3841..c856a9a0d085b278da416c59996fc131 worldData.addProperty("keep-spawn-loaded-range", world.paperConfig().spawn.keepSpawnLoadedRange * 16); diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..6fce2a9bce051e21eba8f331007a9752607f69f2 100644 +index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..a7013fdd8d82f24cadd90ea7e9ebc7c1501042d3 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -128,6 +128,26 @@ public class ChunkHolder { @@ -1748,13 +1748,13 @@ index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..6fce2a9bce051e21eba8f331007a9752 + + public void addPlayer(ServerPlayer player) { + if (!this.playersSentChunkTo.add(player)) { -+ throw new IllegalStateException("Already sent chunk " + this.pos + " to player " + player); ++ throw new IllegalStateException("Already sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player); + } + } + + public void removePlayer(ServerPlayer player) { + if (!this.playersSentChunkTo.remove(player)) { -+ throw new IllegalStateException("Have not sent chunk " + this.pos + " to player " + player); ++ throw new IllegalStateException("Have not sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player); + } + } + @@ -1835,7 +1835,7 @@ index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..6fce2a9bce051e21eba8f331007a9752 // Paper - rewrite chunk system diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index fbe209a66c77c47935ad026dd3e45e682af91fd8..2d133ae656f7420d6ceec14bc591721cff815479 100644 +index fbe209a66c77c47935ad026dd3e45e682af91fd8..78ccfe201f91b9d969766a6aed4ab033a8e1218f 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -199,7 +199,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1878,7 +1878,7 @@ index fbe209a66c77c47935ad026dd3e45e682af91fd8..2d133ae656f7420d6ceec14bc591721c } // Paper end - replace player loader system public void setViewDistance(int watchDistance) { -@@ -826,20 +830,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -826,20 +830,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int k = this.viewDistance; this.viewDistance = j; @@ -1889,6 +1889,8 @@ index fbe209a66c77c47935ad026dd3e45e682af91fd8..2d133ae656f7420d6ceec14bc591721c } public void updateChunkTracking(ServerPlayer player, ChunkPos pos, MutableObject> packet, boolean oldWithinViewDistance, boolean newWithinViewDistance) { // Paper - public // Paper - Anti-Xray - Bypass ++ io.papermc.paper.util.TickThread.ensureTickThread(this.level, pos, "May not update chunk tracking for chunk async"); // Paper - replace chunk loader system ++ io.papermc.paper.util.TickThread.ensureTickThread(player, "May not update chunk tracking for player async"); // Paper - replace chunk loader system if (player.level == this.level) { + ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos.toLong()); // Paper - replace chunk loader system - move up if (newWithinViewDistance && !oldWithinViewDistance) { @@ -1903,19 +1905,26 @@ index fbe209a66c77c47935ad026dd3e45e682af91fd8..2d133ae656f7420d6ceec14bc591721c this.playerLoadedChunk(player, packet, chunk); } -@@ -848,6 +854,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -848,10 +856,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } if (!newWithinViewDistance && oldWithinViewDistance) { + // Paper start - replace chunk loader system + if (playerchunk != null) { + playerchunk.removePlayer(player); ++ } else { ++ LOGGER.warn("ChunkHolder at " + pos + " in world '" + this.level.getWorld().getName() + "' does not exist to untrack chunk for " + player, new Throwable()); + } + // Paper end - replace chunk loader system player.untrackChunk(pos); } -@@ -1151,34 +1162,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +- } ++ } else { LOGGER.warn("Mismatch in world for chunk " + pos + " in world '" + this.level.getWorld().getName() + "' for player " + player, new Throwable()); } // Paper - replace chunk loader system + } + + public int size() { +@@ -1151,34 +1166,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper - replaced by PlayerChunkLoader this.updateMaps(player); // Paper - distance maps @@ -1955,7 +1964,7 @@ index fbe209a66c77c47935ad026dd3e45e682af91fd8..2d133ae656f7420d6ceec14bc591721c // Paper end - per player view distance } -@@ -1612,7 +1607,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1612,7 +1611,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 diff --git a/patches/server/0005-Threaded-Regions.patch b/patches/server/0005-Threaded-Regions.patch index e41520d..7d64e56 100644 --- a/patches/server/0005-Threaded-Regions.patch +++ b/patches/server/0005-Threaded-Regions.patch @@ -13654,7 +13654,7 @@ index a7e133f3495e9132a5fdae2c24f225e7b026295a..7abd4f38ae59a6019137345af960fd60 this.rconConsoleSource.prepareForCommand(); this.executeBlocking(() -> { diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 6fce2a9bce051e21eba8f331007a9752607f69f2..a880cbd4afdf2e540bbe6b62587091c9b5a76ef0 100644 +index a7013fdd8d82f24cadd90ea7e9ebc7c1501042d3..5ccfc95f51a899b1cd3f34af5e5bb05d902016b8 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -85,18 +85,18 @@ public class ChunkHolder { @@ -13708,7 +13708,7 @@ index 6fce2a9bce051e21eba8f331007a9752607f69f2..a880cbd4afdf2e540bbe6b62587091c9 // Paper end - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49de16e614a 100644 +index 78ccfe201f91b9d969766a6aed4ab033a8e1218f..c8bc7db4c22f48047aa409f0bcff3ef8c4034781 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -149,21 +149,21 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -13995,7 +13995,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode mode = level.paperConfig().entities.spawning.duplicateUuid.mode; if (mode != io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.WARN && mode != io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.DELETE -@@ -1010,6 +895,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1014,6 +899,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) { @@ -14034,7 +14034,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d // this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance // tested and confirmed via System.nanoTime() com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet playersInRange = reducedRange ? playerchunk.playersInMobSpawnRange : playerchunk.playersInChunkTickRange; -@@ -1055,7 +972,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1059,7 +976,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return List.of(); } else { Builder builder = ImmutableList.builder(); @@ -14043,7 +14043,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -1084,25 +1001,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1088,25 +1005,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } void updatePlayerStatus(ServerPlayer player, boolean added) { @@ -14074,7 +14074,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d this.removePlayerFromDistanceMaps(player); // Paper - distance maps } -@@ -1121,43 +1031,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1125,43 +1035,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public void move(ServerPlayer player) { // Paper - delay this logic for the entity tracker tick, no need to duplicate it @@ -14119,7 +14119,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d // Paper - replaced by PlayerChunkLoader -@@ -1180,9 +1054,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1184,9 +1058,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public void addEntity(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot // Paper start - ignore and warn about illegal addEntity calls instead of crashing server @@ -14131,7 +14131,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d return; } if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Delay adding to tracker until after list packets -@@ -1195,27 +1069,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1199,27 +1073,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (i != 0) { int j = entitytypes.updateInterval(); @@ -14167,7 +14167,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d } } -@@ -1229,16 +1101,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1233,16 +1105,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider ServerPlayer entityplayer = (ServerPlayer) entity; this.updatePlayerStatus(entityplayer, false); @@ -14191,7 +14191,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d if (playerchunkmap_entitytracker1 != null) { playerchunkmap_entitytracker1.broadcastRemoved(); -@@ -1248,25 +1120,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1252,25 +1124,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start - optimised tracker private final void processTrackQueue() { @@ -14227,7 +14227,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d } // Paper end - optimised tracker -@@ -1277,51 +1142,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1281,51 +1146,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return; } // Paper end - optimized tracker @@ -14281,7 +14281,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcast(packet); -@@ -1330,7 +1156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1334,7 +1160,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected void broadcastAndSend(Entity entity, Packet packet) { @@ -14290,7 +14290,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcastAndSend(packet); -@@ -1517,41 +1343,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1521,41 +1347,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.lastSectionPos = SectionPos.of((EntityAccess) entity); } @@ -14333,7 +14333,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d public boolean equals(Object object) { return object instanceof ChunkMap.TrackedEntity ? ((ChunkMap.TrackedEntity) object).entity.getId() == this.entity.getId() : false; -@@ -1598,6 +1390,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1602,6 +1394,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -14362,7 +14362,7 @@ index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49d public void updatePlayer(ServerPlayer player) { org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot -@@ -1613,10 +1427,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1617,10 +1431,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); // CraftBukkit start - respect vanish API