diff --git a/patches/unapplied/server/0411-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch b/patches/server/0679-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch similarity index 89% rename from patches/unapplied/server/0411-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch rename to patches/server/0679-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch index 14780f2fc1..6d99fc6e6e 100644 --- a/patches/unapplied/server/0411-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch +++ b/patches/server/0679-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimize anyPlayerCloseEnoughForSpawning to use distance maps Use a distance map to find the players in range quickly diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 214e0657035f82e5266de06e31975d6b45405019..51c112656f26f142bd6c126253520e812a338783 100644 +index 4b87f5d899e5ac033d78ccdbca21c9c50c46dcef..b705545ecaef9203ef2ff067ed947ad4aa86dc89 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -83,16 +83,29 @@ public class ChunkHolder { +@@ -86,16 +86,29 @@ public class ChunkHolder { // Paper start public void onChunkAdd() { @@ -38,17 +38,18 @@ index 214e0657035f82e5266de06e31975d6b45405019..51c112656f26f142bd6c126253520e81 + com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet playersInChunkTickRange; + // Paper end - optimise anyPlayerCloseEnoughForSpawning + - public ChunkHolder(ChunkPos pos, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.PlayerProvider playersWatchingChunkProvider, io.papermc.paper.chunk.system.scheduling.NewChunkHolder newChunkHolder) { // Paper - rewrite chunk system - this.newChunkHolder = newChunkHolder; // Paper - rewrite chunk system - this.chunkToSaveHistory = null; + // Paper start - replace player chunk loader + private final com.destroystokyo.paper.util.maplist.ReferenceList playersSentChunkTo = new com.destroystokyo.paper.util.maplist.ReferenceList<>(); + diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c81f84fea 100644 +index 8d8bb430e44d7608a8aa44c7feb41797b8bbfb06..7d80cfd701d910badf1feaecaa4ce5129584e21d 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -159,12 +159,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -157,12 +157,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + // Paper start - distance maps private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); - public final io.papermc.paper.chunk.PlayerChunkLoader playerChunkManager = new io.papermc.paper.chunk.PlayerChunkLoader(this, this.pooledLinkedPlayerHashSets); // Paper - replace chunk loader ++ public final io.papermc.paper.chunk.PlayerChunkLoader playerChunkManager = new io.papermc.paper.chunk.PlayerChunkLoader(this, this.pooledLinkedPlayerHashSets); // Paper - replace chunk loader + // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + // A note about the naming used here: + // Previously, mojang used a "spawn range" of 8 for controlling both ticking and @@ -62,7 +63,7 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c + // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning void addPlayerToDistanceMaps(ServerPlayer player) { - this.playerChunkManager.addPlayer(player); // Paper - replace chunk loader + this.level.playerChunkLoader.addPlayer(player); // Paper - replace chunk loader int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated @@ -70,9 +71,9 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c // Paper start - per player mob spawning if (this.playerMobDistanceMap != null) { this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player)); -@@ -175,6 +187,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -173,6 +186,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider void removePlayerFromDistanceMaps(ServerPlayer player) { - this.playerChunkManager.removePlayer(player); // Paper - replace chunk loader + this.level.playerChunkLoader.removePlayer(player); // Paper - replace chunk loader + // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + this.playerMobSpawnMap.remove(player); @@ -81,15 +82,15 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c // Paper start - per player mob spawning if (this.playerMobDistanceMap != null) { this.playerMobDistanceMap.remove(player); -@@ -187,6 +203,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -185,6 +202,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated - this.playerChunkManager.updatePlayer(player); // Paper - replace chunk loader + this.level.playerChunkLoader.updatePlayer(player); // Paper - replace chunk loader + this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper start - per player mob spawning if (this.playerMobDistanceMap != null) { this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player)); -@@ -278,6 +295,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -276,6 +294,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.regionManagers.add(this.dataRegionManager); // Paper end this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper @@ -128,7 +129,7 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c } protected ChunkGenerator generator() { -@@ -837,43 +886,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -850,43 +900,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return this.anyPlayerCloseEnoughForSpawning(pos, false); } @@ -209,19 +210,19 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c public List getPlayersCloseForSpawning(ChunkPos pos) { diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95474d3238 100644 +index fcbdf311e981e010adc78342f0865d3f803354f9..40e17a8f182fea7c99b64cd074ce1757e48758bf 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java -@@ -54,7 +54,7 @@ public abstract class DistanceManager { - private static final int BLOCK_TICKING_LEVEL_THRESHOLD = 33; +@@ -50,7 +50,7 @@ public abstract class DistanceManager { + private static final int INITIAL_TICKET_LIST_CAPACITY = 4; final Long2ObjectMap> playersPerChunk = new Long2ObjectOpenHashMap(); // Paper - rewrite chunk system - private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); + public static final int MOB_SPAWN_RANGE = 8; // private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); // Paper - no longer used - //private final TickingTracker tickingTicketsTracker = new TickingTracker(); // Paper - no longer used - //private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(33); // Paper - no longer used // Paper - rewrite chunk system -@@ -142,7 +142,7 @@ public abstract class DistanceManager { + private final ChunkMap chunkMap; // Paper + +@@ -136,7 +136,7 @@ public abstract class DistanceManager { long i = chunkcoordintpair.toLong(); // Paper - no longer used @@ -230,7 +231,7 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95 //this.playerTicketManager.update(i, 0, true); // Paper - no longer used //this.tickingTicketsTracker.addTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used } -@@ -156,7 +156,7 @@ public abstract class DistanceManager { +@@ -150,7 +150,7 @@ public abstract class DistanceManager { if (objectset != null) objectset.remove(player); // Paper - some state corruption happens here, don't crash, clean up gracefully. if (objectset == null || objectset.isEmpty()) { // Paper this.playersPerChunk.remove(i); @@ -239,7 +240,7 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95 //this.playerTicketManager.update(i, Integer.MAX_VALUE, false); // Paper - no longer used //this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used } -@@ -198,13 +198,17 @@ public abstract class DistanceManager { +@@ -192,13 +192,17 @@ public abstract class DistanceManager { } public int getNaturalSpawnChunkCount() { @@ -262,10 +263,10 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95 public String getDebugStatus() { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66e9a1d8f0 100644 +index 604e1f1113457d7dbd368d40a668aab7c7466d40..8f1949cf33bdc35d6d024dd82faae37fec325d6f 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -658,6 +658,37 @@ public class ServerChunkCache extends ChunkSource { +@@ -668,6 +668,37 @@ public class ServerChunkCache extends ChunkSource { if (flag) { this.chunkMap.tick(); } else { @@ -303,7 +304,7 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66 LevelData worlddata = this.level.getLevelData(); ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -701,15 +732,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -711,15 +742,7 @@ public class ServerChunkCache extends ChunkSource { boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit Collections.shuffle(list); @@ -320,7 +321,7 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66 Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -717,9 +740,9 @@ public class ServerChunkCache extends ChunkSource { +@@ -727,9 +750,9 @@ public class ServerChunkCache extends ChunkSource { LevelChunk chunk1 = chunkproviderserver_a.chunk; ChunkPos chunkcoordintpair = chunk1.getPos(); @@ -333,14 +334,14 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66 } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 35091999392e7c5e6763aee490020c675e19134b..245ac1e53bfcb1888e8f10d632b181cf31d6d030 100644 +index 6fa598820b54559a5c7739f050be08ff36a020e7..c9b07d321a22060086a8608c6ff5f8f0608d988f 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -272,6 +272,7 @@ public class ServerPlayer extends Player { - public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent +@@ -273,6 +273,7 @@ public class ServerPlayer extends Player { + public Integer clientViewDistance; // CraftBukkit end public boolean isRealPlayer; // Paper + public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event diff --git a/patches/unapplied/server/0699-Optimise-chunk-tick-iteration.patch b/patches/server/0680-Optimise-chunk-tick-iteration.patch similarity index 92% rename from patches/unapplied/server/0699-Optimise-chunk-tick-iteration.patch rename to patches/server/0680-Optimise-chunk-tick-iteration.patch index 27fbd41bbe..4857a6e559 100644 --- a/patches/unapplied/server/0699-Optimise-chunk-tick-iteration.patch +++ b/patches/server/0680-Optimise-chunk-tick-iteration.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimise chunk tick iteration Use a dedicated list of entity ticking chunks to reduce the cost diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd18b4a4525 100644 +index b705545ecaef9203ef2ff067ed947ad4aa86dc89..3914fae62d3e0c0a9aeb8fd2bd48e76889c25a3a 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -88,6 +88,11 @@ public class ChunkHolder { +@@ -91,6 +91,11 @@ public class ChunkHolder { this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key); this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key); // Paper end - optimise anyPlayerCloseEnoughForSpawning @@ -21,7 +21,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1 } public void onChunkRemove() { -@@ -95,6 +100,11 @@ public class ChunkHolder { +@@ -98,6 +103,11 @@ public class ChunkHolder { this.playersInMobSpawnRange = null; this.playersInChunkTickRange = null; // Paper end - optimise anyPlayerCloseEnoughForSpawning @@ -33,7 +33,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1 } // Paper end -@@ -210,7 +220,7 @@ public class ChunkHolder { +@@ -237,7 +247,7 @@ public class ChunkHolder { if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 if (this.changedBlocksPerSection[i] == null) { @@ -42,7 +42,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1 this.changedBlocksPerSection[i] = new ShortOpenHashSet(); } -@@ -234,6 +244,7 @@ public class ChunkHolder { +@@ -261,6 +271,7 @@ public class ChunkHolder { int k = this.lightEngine.getMaxLightSection(); if (y >= j && y <= k) { @@ -50,7 +50,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1 int l = y - j; if (lightType == LightLayer.SKY) { -@@ -248,8 +259,19 @@ public class ChunkHolder { +@@ -275,8 +286,19 @@ public class ChunkHolder { } } @@ -69,13 +69,13 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1 - if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) { + if (this.needsBroadcastChanges()) { // Paper - moved into above, other logic needs to call Level world = chunk.getLevel(); - int i = 0; + List list; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8e09d1713 100644 +index 7d80cfd701d910badf1feaecaa4ce5129584e21d..03b802f9f6e31b1ab23af0ff7b235f64c72ec462 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -116,6 +116,8 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator; +@@ -115,6 +115,8 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator; import org.bukkit.entity.Player; // CraftBukkit end @@ -84,7 +84,7 @@ index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8 public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -154,6 +156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -152,6 +154,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final Queue unloadQueue; int viewDistance; public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper @@ -93,7 +93,7 @@ index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8 // Paper - rewrite chunk system diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1f5fd82c8 100644 +index 8f1949cf33bdc35d6d024dd82faae37fec325d6f..d9a14c1c42ce9adc53543e7b95a4083b4109cb33 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -48,6 +48,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp @@ -104,7 +104,7 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1 public class ServerChunkCache extends ChunkSource { -@@ -724,42 +725,59 @@ public class ServerChunkCache extends ChunkSource { +@@ -725,42 +726,59 @@ public class ServerChunkCache extends ChunkSource { this.lastSpawnState = spawnercreature_d; gameprofilerfiller.popPush("filteringLoadedChunks"); @@ -130,7 +130,8 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1 + // Paper - only shuffle if per-player mob spawning is disabled // Paper - moved natural spawn event up - Iterator iterator1 = list.iterator(); -+ // Paper start - optimise chunk tick iteration + ++ // Paper start - optimise chunk tick iteratio + Iterator iterator1; + if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + iterator1 = this.entityTickingChunks.iterator(); @@ -143,7 +144,6 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1 + Collections.shuffle(shuffled); + iterator1 = shuffled.iterator(); + } - + try { while (iterator1.hasNext()) { - ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next(); @@ -181,7 +181,7 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1 this.level.timings.chunkTicks.stopTiming(); // Paper gameprofilerfiller.popPush("customSpawners"); if (flag2) { -@@ -767,15 +785,24 @@ public class ServerChunkCache extends ChunkSource { +@@ -768,15 +786,24 @@ public class ServerChunkCache extends ChunkSource { this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); } // Paper - timings } diff --git a/patches/unapplied/server/0700-Execute-chunk-tasks-mid-tick.patch b/patches/server/0681-Execute-chunk-tasks-mid-tick.patch similarity index 88% rename from patches/unapplied/server/0700-Execute-chunk-tasks-mid-tick.patch rename to patches/server/0681-Execute-chunk-tasks-mid-tick.patch index ca2778eb52..9b1bb6a636 100644 --- a/patches/unapplied/server/0700-Execute-chunk-tasks-mid-tick.patch +++ b/patches/server/0681-Execute-chunk-tasks-mid-tick.patch @@ -19,10 +19,10 @@ index 4d861f9a58f8ea238471af22f387854d855b1801..efbf77024d235d8af9f7efc938c17afd private MinecraftTimings() {} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 416bfdeb0ce8ec1828288a7d84990ed3f027e1fa..24c88555ea85dd2a0656e1f67a4828a5137157b8 100644 +index b800249823e413933a5d469e431a003f977f59e7..d8fa1cb0b340f97debceb7e5b90051d29448fc58 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1306,6 +1306,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop void guardEntityTick(Consumer tickConsumer, T entity) { try { tickConsumer.accept(entity); diff --git a/patches/unapplied/server/0701-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/0682-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 95% rename from patches/unapplied/server/0701-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to patches/server/0682-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 2ea18be595..23acdc59e2 100644 --- a/patches/unapplied/server/0701-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/0682-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -10,7 +10,7 @@ hoping that at least then we don't swap chunks, and maybe recover them all. diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index f0f38f1a7603cd06aba6adefd370d40b97f2e5b8..34a1976699571608ae19e20dc1b6020759dad909 100644 +index b417b175c925049058327c7bc4ed1cc31a644018..603fcf3816d65d0a695e038d5980b1cd98659f4c 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -70,6 +70,18 @@ import net.minecraft.world.ticks.ProtoChunkTicks; @@ -30,19 +30,19 @@ index f0f38f1a7603cd06aba6adefd370d40b97f2e5b8..34a1976699571608ae19e20dc1b60207 + } + // Paper end - public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null); // Paper - Anti-Xray - Add preset block states + public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); private static final Logger LOGGER = LogUtils.getLogger(); -@@ -485,7 +497,7 @@ public class ChunkSerializer { +@@ -434,7 +446,7 @@ public class ChunkSerializer { nbttagcompound.putInt("xPos", chunkcoordintpair.x); nbttagcompound.putInt("yPos", chunk.getMinSection()); nbttagcompound.putInt("zPos", chunkcoordintpair.z); - nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading + nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading // Paper - diff on change nbttagcompound.putLong("InhabitedTime", chunk.getInhabitedTime()); - nbttagcompound.putString("Status", chunk.getStatus().getName()); + nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(chunk.getStatus()).toString()); BlendingData blendingdata = chunk.getBlendingData(); diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index e9b13e4f70d9a556e6a7d022a952085051c1819d..71abf1c82ee4f5530bd29b3a97dec9fdb7705779 100644 +index b4e7c9b317d532d4915932f8f79dfebf2b63ff16..2d93251abb1018381cf00dbbb120c8ea036710c6 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -41,7 +41,7 @@ public class ChunkStorage implements AutoCloseable { @@ -87,7 +87,7 @@ index c8298a597818227de33a4afce4698ec0666cf758..6baceb6ce9021c489be6e79d338a9704 this.used.set(start, start + size); } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index cda87a66fe80bf910f629c64e36c1fecbad81d77..9bae47f99336c377beb72c4b50b7f01cb4db15da 100644 +index eee5dfa165203463cb791e33530944c6b09e7eb7..98c436d84e4aedbdb805129fcdb6b871a1b4e3d9 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -51,6 +51,355 @@ public class RegionFile implements AutoCloseable { @@ -685,15 +685,20 @@ index cda87a66fe80bf910f629c64e36c1fecbad81d77..9bae47f99336c377beb72c4b50b7f01c return bytebuffer; } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b9d4fbb6a 100644 +index c3d26756a716f151d3909ddfeacc47b28d05c498..5291bbe208397d73e6950e9f196bcd1da55c1fad 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -26,7 +26,15 @@ public class RegionFileStorage implements AutoCloseable { +@@ -25,6 +25,7 @@ public class RegionFileStorage implements AutoCloseable { + public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); private final Path folder; private final boolean sync; - + private final boolean isChunkData; // Paper -+ + + // Paper start - cache regionfile does not exist state + static final int MAX_NON_EXISTING_CACHE = 1024 * 64; +@@ -56,6 +57,12 @@ public class RegionFileStorage implements AutoCloseable { + // Paper end - cache regionfile does not exist state + protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor + // Paper start - add isChunkData param + this(directory, dsync, false); @@ -704,19 +709,25 @@ index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b this.folder = directory; this.sync = dsync; } -@@ -88,9 +96,9 @@ public class RegionFileStorage implements AutoCloseable { - FileUtil.createDirectoriesSafe(this.folder); +@@ -125,7 +132,7 @@ public class RegionFileStorage implements AutoCloseable { + // Paper - only create directory if not existing only - moved down Path path = this.folder; int j = chunkcoordintpair.getRegionX(); - Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); + Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change - if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit + if (existingOnly && !java.nio.file.Files.exists(path1)) { // Paper start - cache regionfile does not exist state + this.markNonExisting(regionPos); + return null; // CraftBukkit +@@ -134,7 +141,7 @@ public class RegionFileStorage implements AutoCloseable { + } + // Paper end - cache regionfile does not exist state + FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above - RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync); + RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header this.regionCache.putAndMoveToFirst(i, regionfile1); // Paper start -@@ -175,6 +183,13 @@ public class RegionFileStorage implements AutoCloseable { +@@ -219,6 +226,13 @@ public class RegionFileStorage implements AutoCloseable { if (regionfile == null) { return null; } @@ -730,7 +741,7 @@ index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b // CraftBukkit end try { // Paper DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); -@@ -191,6 +206,20 @@ public class RegionFileStorage implements AutoCloseable { +@@ -235,6 +249,20 @@ public class RegionFileStorage implements AutoCloseable { try { if (datainputstream != null) { nbttagcompound = NbtIo.read((DataInput) datainputstream); diff --git a/patches/unapplied/server/0702-Custom-table-implementation-for-blockstate-state-loo.patch b/patches/server/0683-Custom-table-implementation-for-blockstate-state-loo.patch similarity index 99% rename from patches/unapplied/server/0702-Custom-table-implementation-for-blockstate-state-loo.patch rename to patches/server/0683-Custom-table-implementation-for-blockstate-state-loo.patch index 30e208f0fe..0318d05517 100644 --- a/patches/unapplied/server/0702-Custom-table-implementation-for-blockstate-state-loo.patch +++ b/patches/server/0683-Custom-table-implementation-for-blockstate-state-loo.patch @@ -173,7 +173,7 @@ index 0000000000000000000000000000000000000000..57d0cd3ad6f972e986c72a57f1a6e360 + } +} diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -index b617f7e7a27284fbbad06d7a9926b938ba87cf18..170f5cb3f01a57ad76e3bbeacd5b7c7e52f29959 100644 +index 89ba12d44865ecddebabbc39c769af4cd8c82702..5f285d190186a2ff5a61d05070593e1d633dd79a 100644 --- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java @@ -39,11 +39,13 @@ public abstract class StateHolder { @@ -217,7 +217,7 @@ index b617f7e7a27284fbbad06d7a9926b938ba87cf18..170f5cb3f01a57ad76e3bbeacd5b7c7e - Comparable comparable = this.values.get(property); - if (comparable == null) { - throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + this.owner); -- } else if (comparable == value) { +- } else if (comparable.equals(value)) { - return (S)this; - } else { - S object = this.neighbours.get(property, value); diff --git a/patches/unapplied/server/0703-Detail-more-information-in-watchdog-dumps.patch b/patches/server/0684-Detail-more-information-in-watchdog-dumps.patch similarity index 94% rename from patches/unapplied/server/0703-Detail-more-information-in-watchdog-dumps.patch rename to patches/server/0684-Detail-more-information-in-watchdog-dumps.patch index 32af3d6ac4..8be8e03bd7 100644 --- a/patches/unapplied/server/0703-Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/0684-Detail-more-information-in-watchdog-dumps.patch @@ -7,10 +7,10 @@ Subject: [PATCH] Detail more information in watchdog dumps - Dump player name, player uuid, position, and world for packet handling diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199..b967c24e9ace2b6539e94bcc63b69e0c934a72be 100644 +index 358b41541284392f9a7a0ef3156e8adc8c005cc4..b7b8ac7f0e93c183e0e7f39cb753f28daace843f 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -522,7 +522,13 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -349,7 +349,13 @@ public class Connection extends SimpleChannelInboundHandler> { if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { @@ -76,10 +76,10 @@ index 4a1148a76020089caf01f888f87afdbb35788dc0..52a84eeb3b7df782cbf91aac6df42fb8 }); throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a 100644 +index 418bf659d31c5810d786064a76779cfa39943020..f8bcf1239c18a6334936cec483f2ae316429a894 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1059,7 +1059,26 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1119,7 +1119,26 @@ public class ServerLevel extends Level implements WorldGenLevel { } @@ -106,7 +106,7 @@ index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd1 ++TimingHistory.entityTicks; // Paper - timings // Spigot start co.aikar.timings.Timing timer; // Paper -@@ -1099,7 +1118,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1159,7 +1178,13 @@ public class ServerLevel extends Level implements WorldGenLevel { this.tickPassenger(entity, entity1); } // } finally { timer.stopTiming(); } // Paper - timings - move up @@ -122,10 +122,10 @@ index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd1 private void tickPassenger(Entity vehicle, Entity passenger) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5ab632dd7 100644 +index fe750fd202f9a2a02f07752a11b1a4a8368afa5e..eb9f56de921edfefc0655be47449ffbc97145e07 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -973,7 +973,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -991,7 +991,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.onGround; } @@ -168,8 +168,8 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5 if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { -@@ -1146,6 +1181,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - this.level.getProfiler().pop(); +@@ -1187,6 +1222,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return false; } } + // Paper start - detailed watchdog information @@ -182,7 +182,7 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5 } protected boolean isHorizontalCollisionMinor(Vec3 adjustedMovement) { -@@ -4098,7 +4140,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4197,7 +4239,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void setDeltaMovement(Vec3 velocity) { @@ -192,7 +192,7 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5 } public void addDeltaMovement(Vec3 velocity) { -@@ -4184,7 +4228,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4283,7 +4327,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Paper end - fix MC-4 if (this.position.x != x || this.position.y != y || this.position.z != z) { diff --git a/patches/unapplied/server/0704-Manually-inline-methods-in-BlockPosition.patch b/patches/server/0685-Manually-inline-methods-in-BlockPosition.patch similarity index 91% rename from patches/unapplied/server/0704-Manually-inline-methods-in-BlockPosition.patch rename to patches/server/0685-Manually-inline-methods-in-BlockPosition.patch index 4d6e132a91..c8b8adfce9 100644 --- a/patches/unapplied/server/0704-Manually-inline-methods-in-BlockPosition.patch +++ b/patches/server/0685-Manually-inline-methods-in-BlockPosition.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Manually inline methods in BlockPosition diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index 5a42e0315fb44c2a0390c51b123501498140238a..b37e0ff164a894d2033fb94bbbc2f630a0e66bcd 100644 +index 441ea6b9fd55a5288f264472d7297728d0546d6b..83cab746d1d6fe25c043c8aee28c39412b90c127 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -474,9 +474,9 @@ public class BlockPos extends Vec3i { +@@ -515,9 +515,9 @@ public class BlockPos extends Vec3i { } public BlockPos.MutableBlockPos set(int x, int y, int z) { @@ -21,7 +21,7 @@ index 5a42e0315fb44c2a0390c51b123501498140238a..b37e0ff164a894d2033fb94bbbc2f630 return this; } -@@ -540,19 +540,19 @@ public class BlockPos extends Vec3i { +@@ -581,19 +581,19 @@ public class BlockPos extends Vec3i { // Paper start - comment out useless overrides @Override - TODO figure out why this is suddenly important to keep @Override public BlockPos.MutableBlockPos setX(int i) {