diff --git a/patches/server/0004-Paper-config-files.patch b/patches/server/0004-Paper-config-files.patch index 43bda5596..fa4ca2088 100644 --- a/patches/server/0004-Paper-config-files.patch +++ b/patches/server/0004-Paper-config-files.patch @@ -661,10 +661,10 @@ index 882fe0e84c0607c69ad729aa7732f41554975c82..ebd94265f56ecc946ff1834ec0d45673 this.setPvpAllowed(dedicatedserverproperties.pvp); this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index b1a9ac4bb5f5f7b55a722b60994672c6a2f3406d..2015e527044db26bed960b2915b5422a7d7ad0e3 100644 +index 081c324b42cea97fce2220aa2c86d02daef7688f..7c034b62dbebbbc4c9c4ceb427b1509fe8f986e3 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -334,6 +334,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -326,6 +326,12 @@ public class ServerChunkCache extends ChunkSource { } } @@ -777,7 +777,7 @@ index 05364e743e5000f1eff292b17bbd19dae58e3dac..e71bc0315f9e4559e2df6a83a3c11f10 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index b698d6a8d6b59eefd721639b62bfd8bcffcf5c6f..70aa37fe043f56ef1b2f722ca946c4ac2cf4a98b 100644 +index e75ff70c52b097af447b7a91ef2c20c08a904d92..fae37b7b353cb7b0f8d4a79407fcc219a3c45b64 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -129,6 +129,14 @@ public class Main { diff --git a/patches/server/0005-MC-Dev-fixes.patch b/patches/server/0005-MC-Dev-fixes.patch index 5ad555fdc..ee563f2c5 100644 --- a/patches/server/0005-MC-Dev-fixes.patch +++ b/patches/server/0005-MC-Dev-fixes.patch @@ -345,16 +345,3 @@ index e6b1663d4ccdd3842f711ad7547df8ccf973e4b1..524f3c42964eb83c9109bcc548a1075f } } -diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -index f1aee097318f91d582aa143a77662ec12e812c93..3f46bf0358fd9bb4d0fa41026f138ffd21952bde 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -@@ -35,7 +35,7 @@ import org.apache.commons.lang3.StringUtils; - import org.slf4j.Logger; - - public class WorldGenSettings { -- public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -+ public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { // Paper - decompile fix - return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(WorldGenSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldGenSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldGenSettings::generateBonusChest), RegistryCodecs.dataPackAwareCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity()).fieldOf("dimensions").forGetter(WorldGenSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((worldGenSettings) -> { - return worldGenSettings.legacyCustomOptions; - })).apply(instance, instance.stable(WorldGenSettings::new)); diff --git a/patches/server/0007-MC-Utils.patch b/patches/server/0007-MC-Utils.patch index 62f302bab..f8b5ec815 100644 --- a/patches/server/0007-MC-Utils.patch +++ b/patches/server/0007-MC-Utils.patch @@ -5052,7 +5052,7 @@ index 868f6799a0e406401eecf18bc939fbdf88f534a2..dd8d14a1b128f801a4e1c811de5990d2 } catch (Throwable throwable) { // Spigot Start diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81eff0e4358 100644 +index a6dc73ddb58465667b9e227bece32f2952aa2270..e9523a7a3e1c6ee944ba539b952c8f25350bf815 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -52,9 +52,9 @@ public class ChunkHolder { @@ -5077,26 +5077,20 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e 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.fullChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE; -@@ -93,8 +95,30 @@ public class ChunkHolder { +@@ -93,8 +95,23 @@ public class ChunkHolder { this.queueLevel = this.oldTicketLevel; this.setTicketLevel(level); this.changedBlocksPerSection = new ShortSet[world.getSectionsCount()]; + this.chunkMap = (ChunkMap)playersWatchingChunkProvider; // Paper -+ } -+ -+ // Paper start -+ public LevelChunk getFullChunkUnchecked() { -+ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); -+ Either either = (Either) statusFuture.getNow(null); -+ return (either == null) ? null : (LevelChunk) either.left().orElse(null); } -+ public ChunkAccess getAvailableChunkNow() { ++ // Paper start ++ public @Nullable ChunkAccess getAvailableChunkNow() { + // TODO can we just getStatusFuture(EMPTY)? + for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) { + CompletableFuture> future = this.getFutureIfPresentUnchecked(curr); + Either either = future.getNow(null); -+ if (either == null || !either.left().isPresent()) { ++ if (either == null || either.left().isEmpty()) { + continue; + } + return either.left().get(); @@ -5104,11 +5098,10 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e + return null; + } + // Paper end -+ - public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus leastStatus) { - CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(leastStatus.getIndex()); - -@@ -105,20 +129,20 @@ public class ChunkHolder { + // CraftBukkit start + public LevelChunk getFullChunkNow() { + // Note: We use the oldTicketLevel for isLoaded checks. +@@ -119,20 +136,20 @@ public class ChunkHolder { return ChunkHolder.getStatus(this.ticketLevel).isOrAfter(leastStatus) ? this.getFutureIfPresentUnchecked(leastStatus) : ChunkHolder.UNLOADED_CHUNK_FUTURE; } @@ -5133,7 +5126,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e CompletableFuture> completablefuture = this.getTickingChunkFuture(); Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error -@@ -126,7 +150,7 @@ public class ChunkHolder { +@@ -140,7 +157,7 @@ public class ChunkHolder { } @Nullable @@ -5142,7 +5135,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e CompletableFuture> completablefuture = this.getFullChunkFuture(); Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error -@@ -147,6 +171,21 @@ public class ChunkHolder { +@@ -161,6 +178,21 @@ public class ChunkHolder { return null; } @@ -5164,7 +5157,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e @Nullable public ChunkAccess getLastAvailable() { for (int i = ChunkHolder.CHUNK_STATUSES.size() - 1; i >= 0; --i) { -@@ -165,7 +204,7 @@ public class ChunkHolder { +@@ -179,7 +211,7 @@ public class ChunkHolder { return null; } @@ -5173,7 +5166,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e return this.chunkToSave; } -@@ -342,11 +381,11 @@ public class ChunkHolder { +@@ -356,11 +388,11 @@ public class ChunkHolder { return ChunkHolder.getFullChunkStatus(this.ticketLevel); } @@ -5187,7 +5180,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e return this.ticketLevel; } -@@ -435,14 +474,27 @@ public class ChunkHolder { +@@ -449,14 +481,27 @@ public class ChunkHolder { this.wasAccessibleSinceLastSave |= flag3; if (!flag2 && flag3) { @@ -5215,7 +5208,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e } boolean flag4 = playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.TICKING); -@@ -451,12 +503,29 @@ public class ChunkHolder { +@@ -465,12 +510,29 @@ public class ChunkHolder { if (!flag4 && flag5) { this.tickingChunkFuture = chunkStorage.prepareTickingChunk(this); this.scheduleFullChunkPromotion(chunkStorage, this.tickingChunkFuture, executor, ChunkHolder.FullChunkStatus.TICKING); @@ -5238,7 +5231,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e + this.tickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isTickingReady = false; // Paper - cache chunk ticking stage this.tickingChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE; + // Paper start - ticking chunk set -+ LevelChunk chunkIfCached = this.getFullChunkUnchecked(); ++ LevelChunk chunkIfCached = this.getFullChunkNowUnchecked(); + if (chunkIfCached != null) { + this.chunkMap.level.getChunkSource().tickingChunks.remove(chunkIfCached); + } @@ -5246,7 +5239,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e } boolean flag6 = playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.ENTITY_TICKING); -@@ -469,12 +538,28 @@ public class ChunkHolder { +@@ -483,12 +545,28 @@ public class ChunkHolder { this.entityTickingChunkFuture = chunkStorage.prepareEntityTickingChunk(this.pos); this.scheduleFullChunkPromotion(chunkStorage, this.entityTickingChunkFuture, executor, ChunkHolder.FullChunkStatus.ENTITY_TICKING); @@ -5268,7 +5261,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e + this.entityTickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage this.entityTickingChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE; + // Paper start - entity ticking chunk set -+ LevelChunk chunkIfCached = this.getFullChunkUnchecked(); ++ LevelChunk chunkIfCached = this.getFullChunkNowUnchecked(); + if (chunkIfCached != null) { + this.chunkMap.level.getChunkSource().entityTickingChunks.remove(chunkIfCached); + } @@ -5276,7 +5269,7 @@ index d1a053dbade32fde28784c79659d9b150c90ed93..2b936c67265f3c672d3b623e6aedd81e } if (!playerchunk_state1.isOrAfter(playerchunk_state)) { -@@ -590,4 +675,18 @@ public class ChunkHolder { +@@ -604,4 +682,18 @@ public class ChunkHolder { } }; } @@ -5496,7 +5489,7 @@ index 6c98676827ceb6999f340fa2b06a0b3e1cb4cae2..f08089b8672454acf8c2309e850466b3 while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 2015e527044db26bed960b2915b5422a7d7ad0e3..94d717f43336ace9375409b48d1e0e4291072656 100644 +index 7c034b62dbebbbc4c9c4ceb427b1509fe8f986e3..e4d0035bbf17008642cdcc0e1dca5bae832bbbaa 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -49,6 +49,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; @@ -5842,7 +5835,7 @@ index 2015e527044db26bed960b2915b5422a7d7ad0e3..94d717f43336ace9375409b48d1e0e42 public ServerChunkCache(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory) { this.level = world; -@@ -127,6 +456,49 @@ public class ServerChunkCache extends ChunkSource { +@@ -119,6 +448,49 @@ public class ServerChunkCache extends ChunkSource { this.lastChunk[0] = chunk; } @@ -5859,7 +5852,7 @@ index 2015e527044db26bed960b2915b5422a7d7ad0e3..94d717f43336ace9375409b48d1e0e42 + return null; + } + -+ return playerChunk.getFullChunkUnchecked(); ++ return playerChunk.getFullChunkNowUnchecked(); + } + + @Nullable diff --git a/patches/server/0012-Timings-v2.patch b/patches/server/0012-Timings-v2.patch index ef08cbc66..6cc67ec1d 100644 --- a/patches/server/0012-Timings-v2.patch +++ b/patches/server/0012-Timings-v2.patch @@ -1118,10 +1118,10 @@ index d9202f7a5b17d8a5c063c8aba4ce22a53d8f59af..f9e9e00855627b78e8ff018bf6d52c97 } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 94d717f43336ace9375409b48d1e0e4291072656..3bbee4d08f4125a6499c0a8790c6bda6935e5ccc 100644 +index e4d0035bbf17008642cdcc0e1dca5bae832bbbaa..d198303d4d0cff34156c00176ec2f3f2ad42ada4 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -524,13 +524,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -516,13 +516,15 @@ public class ServerChunkCache extends ChunkSource { } gameprofilerfiller.incrementCounter("getChunkCacheMiss"); @@ -1139,7 +1139,7 @@ index 94d717f43336ace9375409b48d1e0e4291072656..3bbee4d08f4125a6499c0a8790c6bda6 ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; }, (playerchunk_failure) -> { -@@ -728,7 +730,9 @@ public class ServerChunkCache extends ChunkSource { +@@ -720,7 +722,9 @@ public class ServerChunkCache extends ChunkSource { public void save(boolean flush) { this.runDistanceManagerUpdates(); @@ -1149,7 +1149,7 @@ index 94d717f43336ace9375409b48d1e0e4291072656..3bbee4d08f4125a6499c0a8790c6bda6 } @Override -@@ -767,7 +771,9 @@ public class ServerChunkCache extends ChunkSource { +@@ -759,7 +763,9 @@ public class ServerChunkCache extends ChunkSource { this.level.timings.doChunkMap.stopTiming(); // Spigot this.level.getProfiler().popPush("chunks"); if (tickChunks) { @@ -1159,7 +1159,7 @@ index 94d717f43336ace9375409b48d1e0e4291072656..3bbee4d08f4125a6499c0a8790c6bda6 } this.level.timings.doChunkUnload.startTiming(); // Spigot -@@ -796,13 +802,16 @@ public class ServerChunkCache extends ChunkSource { +@@ -788,13 +794,16 @@ public class ServerChunkCache extends ChunkSource { boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit gameprofilerfiller.push("naturalSpawnCount"); @@ -1176,7 +1176,7 @@ index 94d717f43336ace9375409b48d1e0e4291072656..3bbee4d08f4125a6499c0a8790c6bda6 while (iterator.hasNext()) { ChunkHolder playerchunk = (ChunkHolder) iterator.next(); -@@ -831,27 +840,27 @@ public class ServerChunkCache extends ChunkSource { +@@ -823,27 +832,27 @@ public class ServerChunkCache extends ChunkSource { } if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { diff --git a/patches/server/0168-PlayerNaturallySpawnCreaturesEvent.patch b/patches/server/0168-PlayerNaturallySpawnCreaturesEvent.patch index 4086c32b0..868886cb8 100644 --- a/patches/server/0168-PlayerNaturallySpawnCreaturesEvent.patch +++ b/patches/server/0168-PlayerNaturallySpawnCreaturesEvent.patch @@ -40,10 +40,10 @@ index f5cf71258732aa040443eb82e09ab28f130e4c79..81eb73e9fde37e3b196bd899ecd4d614 return true; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 3bbee4d08f4125a6499c0a8790c6bda6935e5ccc..efb735f2cf0d232db83ade7332250e455c276bea 100644 +index d198303d4d0cff34156c00176ec2f3f2ad42ada4..f2d92cd125cbc1bd6fdab774e7002d6b7eda29fc 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -826,6 +826,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -818,6 +818,15 @@ public class ServerChunkCache extends ChunkSource { boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit Collections.shuffle(list); diff --git a/patches/server/0253-Asynchronous-chunk-IO-and-loading.patch b/patches/server/0253-Asynchronous-chunk-IO-and-loading.patch index a5c8c1203..0509d1308 100644 --- a/patches/server/0253-Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/0253-Asynchronous-chunk-IO-and-loading.patch @@ -2331,10 +2331,10 @@ index d6e6bc73f9bbcae99126876a9abdd3468d6c2a7f..785df5ec8a5a4e307149edd5ccf7db75 public String getLocalIp() { diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 2b936c67265f3c672d3b623e6aedd81eff0e4358..d930162608e1b765ef222eb0fe61d010c6fa97f1 100644 +index e9523a7a3e1c6ee944ba539b952c8f25350bf815..41fe4c01c2876dcb2372c4b412c8927359cf74d7 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -425,7 +425,7 @@ public class ChunkHolder { +@@ -432,7 +432,7 @@ public class ChunkHolder { ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel); ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel); boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE; @@ -2600,10 +2600,10 @@ index f08089b8672454acf8c2309e850466b335248692..ab785bfc29c0b120b7c6fed2d15460c8 while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index efb735f2cf0d232db83ade7332250e455c276bea..b6737c0b74e821c948919ca4184dfe0281a19894 100644 +index f2d92cd125cbc1bd6fdab774e7002d6b7eda29fc..98f3b91605ecf81538659220354f78d4de9d203e 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -498,10 +498,111 @@ public class ServerChunkCache extends ChunkSource { +@@ -490,10 +490,111 @@ public class ServerChunkCache extends ChunkSource { return ret; } // Paper end @@ -2715,7 +2715,7 @@ index efb735f2cf0d232db83ade7332250e455c276bea..b6737c0b74e821c948919ca4184dfe02 if (Thread.currentThread() != this.mainThread) { return (ChunkAccess) CompletableFuture.supplyAsync(() -> { return this.getChunk(x, z, leastStatus, create); -@@ -524,13 +625,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -516,13 +617,18 @@ public class ServerChunkCache extends ChunkSource { } gameprofilerfiller.incrementCounter("getChunkCacheMiss"); @@ -2735,7 +2735,7 @@ index efb735f2cf0d232db83ade7332250e455c276bea..b6737c0b74e821c948919ca4184dfe02 this.level.timings.syncChunkLoad.stopTiming(); // Paper } // Paper ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { -@@ -617,6 +723,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -609,6 +715,11 @@ public class ServerChunkCache extends ChunkSource { } private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { @@ -2747,7 +2747,7 @@ index efb735f2cf0d232db83ade7332250e455c276bea..b6737c0b74e821c948919ca4184dfe02 ChunkPos chunkcoordintpair = new ChunkPos(chunkX, chunkZ); long k = chunkcoordintpair.toLong(); int l = 33 + ChunkStatus.getDistance(leastStatus); -@@ -1036,11 +1147,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -1028,11 +1139,12 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task public boolean pollTask() { try { @@ -3562,7 +3562,7 @@ index 4160a35ecfa1c28b88d6ebbfd14a0be1933e3b6d..3e08ff74979c78b27537403bbcaf1345 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 16926ecc4a67951d58c1794a64a408dbd9943a30..440a3cb699939b0b1224a4668f0e221f9c7f3159 100644 +index 11c9c33e560304c868991e9f6e4dc0040fbe06e9..68d6f6b9edab370aaaf6a0113aaf7563770db229 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1875,6 +1875,34 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0325-Chunk-debug-command.patch b/patches/server/0325-Chunk-debug-command.patch index 1f845abc5..21f6eaae6 100644 --- a/patches/server/0325-Chunk-debug-command.patch +++ b/patches/server/0325-Chunk-debug-command.patch @@ -32,7 +32,7 @@ https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528273&page=com.atlass https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528577&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-528577 diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 1eb45df9dca5d0c31ac46709e706136a246cb8ea..005361c38b02713fb823d0be40954400d59f0c4d 100644 +index 1eb45df9dca5d0c31ac46709e706136a246cb8ea..53e290aa5c90b241f8d817b4eede08da140197cd 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -6,13 +6,15 @@ import com.google.common.collect.ImmutableSet; @@ -132,7 +132,7 @@ index 1eb45df9dca5d0c31ac46709e706136a246cb8ea..005361c38b02713fb823d0be40954400 + int entityTicking = 0; + + for (ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunkMap.values()) { -+ if (chunk.getFullChunkUnchecked() == null) { ++ if (chunk.getFullChunkNowUnchecked() == null) { + continue; + } + @@ -212,7 +212,7 @@ index 1eb45df9dca5d0c31ac46709e706136a246cb8ea..005361c38b02713fb823d0be40954400 * Ported from MinecraftForge - author: LexManos - License: LGPLv2.1 */ diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 162aa7718488a74980843944e0d026ccfd5a65a5..89e0181af99cba2368f875fc192342efc972f2ef 100644 +index 162aa7718488a74980843944e0d026ccfd5a65a5..defeba92b2a7a5d9d5031f2adc0581d87070bb47 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -9,13 +9,27 @@ import net.minecraft.core.BlockPos; @@ -334,7 +334,7 @@ index 162aa7718488a74980843944e0d026ccfd5a65a5..89e0181af99cba2368f875fc192342ef + int fullLoadedChunks = 0; + + for (ChunkHolder chunk : allChunks) { -+ if (chunk.getFullChunkUnchecked() != null) { ++ if (chunk.getFullChunkNowUnchecked() != null) { + ++fullLoadedChunks; + } + } diff --git a/patches/server/0360-implement-optional-per-player-mob-spawns.patch b/patches/server/0360-implement-optional-per-player-mob-spawns.patch index 30385c65e..f5d814499 100644 --- a/patches/server/0360-implement-optional-per-player-mob-spawns.patch +++ b/patches/server/0360-implement-optional-per-player-mob-spawns.patch @@ -370,10 +370,10 @@ index 1e066a35b53b1f71a0e6376a22d51fc4c0a412dc..6228f2f67541da62b0ae093de987662d this.naturalSpawnChunkCounter.runAllUpdates(); return this.naturalSpawnChunkCounter.chunks.size(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index b6737c0b74e821c948919ca4184dfe0281a19894..cbb8adea5e867a92e1dc4c94a0e7e116b7ac2274 100644 +index 98f3b91605ecf81538659220354f78d4de9d203e..39b4ddbb87e6ec2e8103445625ff0d7d368bd513 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -915,7 +915,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -907,7 +907,18 @@ public class ServerChunkCache extends ChunkSource { gameprofilerfiller.push("naturalSpawnCount"); this.level.timings.countNaturalMobs.startTiming(); // Paper - timings int l = this.distanceManager.getNaturalSpawnChunkCount(); diff --git a/patches/server/0363-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/patches/server/0363-Optimise-getChunkAt-calls-for-loaded-chunks.patch index d84613d8f..7c34763e9 100644 --- a/patches/server/0363-Optimise-getChunkAt-calls-for-loaded-chunks.patch +++ b/patches/server/0363-Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -7,10 +7,10 @@ bypass the need to get a player chunk, then get the either, then unwrap it... diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index cbb8adea5e867a92e1dc4c94a0e7e116b7ac2274..e05f3c197c072860a3242ccfb41ba68609be748d 100644 +index 39b4ddbb87e6ec2e8103445625ff0d7d368bd513..dec6aab50cebdfe1d0c93d71a8579b78b0ef7b9d 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -608,6 +608,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -600,6 +600,12 @@ public class ServerChunkCache extends ChunkSource { return this.getChunk(x, z, leastStatus, create); }, this.mainThreadProcessor).join(); } else { @@ -23,7 +23,7 @@ index cbb8adea5e867a92e1dc4c94a0e7e116b7ac2274..e05f3c197c072860a3242ccfb41ba686 ProfilerFiller gameprofilerfiller = this.level.getProfiler(); gameprofilerfiller.incrementCounter("getChunk"); -@@ -659,39 +665,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -651,39 +657,7 @@ public class ServerChunkCache extends ChunkSource { if (Thread.currentThread() != this.mainThread) { return null; } else { diff --git a/patches/server/0364-Add-debug-for-sync-chunk-loads.patch b/patches/server/0364-Add-debug-for-sync-chunk-loads.patch index 328659c04..c97f45465 100644 --- a/patches/server/0364-Add-debug-for-sync-chunk-loads.patch +++ b/patches/server/0364-Add-debug-for-sync-chunk-loads.patch @@ -13,7 +13,7 @@ chunks, however it must be enabled by setting the startup flag /paper syncloadinfo clear diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 3091c100eaf5a86ba270ef0d96de1852a2a0ac9e..51e469146f0712a509071c8438ff6b69f961f945 100644 +index 0c0a8b93e67792aa641e1cb929a11f62cfa38e33..abd8edc1c3e9dfe0df1828761f87c33318c14143 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -1,11 +1,17 @@ @@ -305,10 +305,10 @@ index 0000000000000000000000000000000000000000..0bb4aaa546939b67a5d22865190f3047 + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index e05f3c197c072860a3242ccfb41ba68609be748d..cf56b2ed508352205ef6ec71519b0626aa698987 100644 +index dec6aab50cebdfe1d0c93d71a8579b78b0ef7b9d..8f1609bbb5670d3b4acccb2cb4b9238ce13290bb 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -640,6 +640,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -632,6 +632,7 @@ public class ServerChunkCache extends ChunkSource { this.level.asyncChunkTaskManager.raisePriority(x1, z1, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY); com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.level, x1, z1); // Paper end @@ -317,7 +317,7 @@ index e05f3c197c072860a3242ccfb41ba68609be748d..cf56b2ed508352205ef6ec71519b0626 chunkproviderserver_b.managedBlock(completablefuture::isDone); com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index cadefabbbecdba5e6002c94c2df34dd0b7b76991..2119a0cb18edffb88150451446f488b763db977c 100644 +index 8c91e1de2bd9a42259be32322eb36d4979684edc..e0e6915320264da3fefb3f449f27efb8477e1e63 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -383,6 +383,12 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/0365-Remove-garbage-Java-version-check.patch b/patches/server/0365-Remove-garbage-Java-version-check.patch index c13ba5e83..3c72a283d 100644 --- a/patches/server/0365-Remove-garbage-Java-version-check.patch +++ b/patches/server/0365-Remove-garbage-Java-version-check.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Remove garbage Java version check diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 2695f047a2e3c7acb67487c2b547cfbd6d50c29c..69b7a11d423b1cd8560cd726dd2b9a2b203e7dfd 100644 +index ee9f7f42a0eeb3c6f9930e227eeda26ba362e7f4..69b7a11d423b1cd8560cd726dd2b9a2b203e7dfd 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -189,10 +189,6 @@ public class Main { System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 17. Check your Java version with the command 'java -version'."); return; } -- if (javaVersion > 61.0) { -- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 17 is supported."); +- if (javaVersion > 62.0) { +- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 18 is supported."); - return; - } diff --git a/patches/server/0398-Fix-Chunk-Post-Processing-deadlock-risk.patch b/patches/server/0398-Fix-Chunk-Post-Processing-deadlock-risk.patch index 0f3fb79f5..240ccc234 100644 --- a/patches/server/0398-Fix-Chunk-Post-Processing-deadlock-risk.patch +++ b/patches/server/0398-Fix-Chunk-Post-Processing-deadlock-risk.patch @@ -60,10 +60,10 @@ index 7776c22744cdd31459e9634d1d549bdf2876e04f..43e5e148f1289ff5e42311981c597c66 completablefuture1.thenAcceptAsync((either) -> { either.ifLeft((chunk) -> { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index cf56b2ed508352205ef6ec71519b0626aa698987..1b6fb81079d3ad5d3c33be67a1c05111f9dd5f2d 100644 +index 8f1609bbb5670d3b4acccb2cb4b9238ce13290bb..cf5a5d98420c3849621bfdfae7bda7d5cb4b2dc9 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -1141,6 +1141,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1133,6 +1133,7 @@ public class ServerChunkCache extends ChunkSource { return super.pollTask() || execChunkTask; // Paper } } finally { diff --git a/patches/server/0428-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch b/patches/server/0428-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch index a93b866c4..de647c189 100644 --- a/patches/server/0428-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch +++ b/patches/server/0428-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch @@ -6,7 +6,7 @@ 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 674a6492e2eb10cfd29989643eedcea08b2d5218..dff475b327d6edaa4dcb9bc09029237f8f659846 100644 +index 8356a0e816324ce67df14151bdc186e60d8a223c..1324d48ff7540c4fe9148b3c6d4952ebbfb3fc22 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -76,6 +76,23 @@ public class ChunkHolder { @@ -286,10 +286,10 @@ index 4a9d0fca55b71f817defcb4286154c0a47bede03..62118348d6fb00f063507debb488e1ff 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 1b6fb81079d3ad5d3c33be67a1c05111f9dd5f2d..1d5587bb9cf785de4b6d59234eb700c2e1a8a7dd 100644 +index cf5a5d98420c3849621bfdfae7bda7d5cb4b2dc9..846e6f41fdb6413b10f908c6b3f5c199a9f5ef38 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -880,6 +880,37 @@ public class ServerChunkCache extends ChunkSource { +@@ -872,6 +872,37 @@ public class ServerChunkCache extends ChunkSource { if (flag) { this.chunkMap.tick(); } else { @@ -327,7 +327,7 @@ index 1b6fb81079d3ad5d3c33be67a1c05111f9dd5f2d..1d5587bb9cf785de4b6d59234eb700c2 LevelData worlddata = this.level.getLevelData(); ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -923,15 +954,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -915,15 +946,7 @@ public class ServerChunkCache extends ChunkSource { boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit Collections.shuffle(list); @@ -344,7 +344,7 @@ index 1b6fb81079d3ad5d3c33be67a1c05111f9dd5f2d..1d5587bb9cf785de4b6d59234eb700c2 Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -939,9 +962,9 @@ public class ServerChunkCache extends ChunkSource { +@@ -931,9 +954,9 @@ public class ServerChunkCache extends ChunkSource { LevelChunk chunk1 = chunkproviderserver_a.chunk; ChunkPos chunkcoordintpair = chunk1.getPos(); diff --git a/patches/server/0452-incremental-chunk-and-player-saving.patch b/patches/server/0452-incremental-chunk-and-player-saving.patch index e8198919a..7dfa4660d 100644 --- a/patches/server/0452-incremental-chunk-and-player-saving.patch +++ b/patches/server/0452-incremental-chunk-and-player-saving.patch @@ -98,7 +98,7 @@ index 03ef045c166c92efaeeaf655178b9729549e2296..851d63ba918f1fb2ffb975b0b46c8797 // Paper start - move executeAll() into full server tick timing try (co.aikar.timings.Timing ignored = MinecraftTimings.processTasksTimer.startTiming()) { diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index dff475b327d6edaa4dcb9bc09029237f8f659846..05d2790b80a6d2e1dc6b8d2375f783be4eff2343 100644 +index 1324d48ff7540c4fe9148b3c6d4952ebbfb3fc22..71af341580f08c71f4c4e6c758955cad14e7530d 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -92,6 +92,8 @@ public class ChunkHolder { @@ -110,7 +110,7 @@ index dff475b327d6edaa4dcb9bc09029237f8f659846..05d2790b80a6d2e1dc6b8d2375f783be public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) { this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size()); -@@ -491,7 +493,19 @@ public class ChunkHolder { +@@ -498,7 +500,19 @@ public class ChunkHolder { boolean flag2 = playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.BORDER); boolean flag3 = playerchunk_state1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER); @@ -130,7 +130,7 @@ index dff475b327d6edaa4dcb9bc09029237f8f659846..05d2790b80a6d2e1dc6b8d2375f783be if (!flag2 && flag3) { int expectCreateCount = ++this.fullChunkCreateCount; // Paper this.fullChunkFuture = chunkStorage.prepareAccessibleChunk(this); -@@ -622,9 +636,33 @@ public class ChunkHolder { +@@ -629,9 +643,33 @@ public class ChunkHolder { } public void refreshAccessibility() { @@ -281,10 +281,10 @@ index 2c9cd3619b0759905637eff746a761ebe89a38d8..1614b056d9e0c9e6b62d6c6a8926e87b ChunkPos chunkcoordintpair = chunk.getPos(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 1d5587bb9cf785de4b6d59234eb700c2e1a8a7dd..9fdd2a39e3590b3098fa31b9b0e0081160819630 100644 +index 846e6f41fdb6413b10f908c6b3f5c199a9f5ef38..9079e469161098e1520f6b9fd963adedd500024b 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -821,6 +821,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -813,6 +813,15 @@ public class ServerChunkCache extends ChunkSource { } // Paper - Timings } @@ -301,7 +301,7 @@ index 1d5587bb9cf785de4b6d59234eb700c2e1a8a7dd..9fdd2a39e3590b3098fa31b9b0e00811 public void close() throws IOException { // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 2fed7a347844a24a1095a654f27c1494a53eef51..2182d17d463cea2ff999c5bc61eb31f4317362d8 100644 +index 42d7802e787d1e2722bf94487f9bf8383aeef660..c77f464b772e72c23fe00e99bc0fee24d46fb16b 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1061,6 +1061,37 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -343,7 +343,7 @@ index 2fed7a347844a24a1095a654f27c1494a53eef51..2182d17d463cea2ff999c5bc61eb31f4 ServerChunkCache chunkproviderserver = this.getChunkSource(); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 5a4eeb46543d9458e309e2d4cc56086b5cf528c6..d11b5c9e64b6695a44cc2db588bed2e8a870c607 100644 +index dda1bf2406f8899d73f26c642f6a4ec03dea0415..b290262b4f765c85847f8846d26f4341f39a826a 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -169,6 +169,7 @@ import org.bukkit.inventory.MainHand; diff --git a/patches/server/0466-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch b/patches/server/0466-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch index 7c43beb1b..8601bd6cc 100644 --- a/patches/server/0466-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch +++ b/patches/server/0466-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch @@ -68,7 +68,7 @@ index 80c785eb503dc36d381f114a4eccffc1a81071f7..311a01d3590dabc7a4e41bb3493cd7ff } diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 89e0181af99cba2368f875fc192342efc972f2ef..b3516862d796c2d9fcc1c67a6073445403d73088 100644 +index defeba92b2a7a5d9d5031f2adc0581d87070bb47..a6bcf936747720202857ba586fa35c46c9c91caf 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -681,6 +681,7 @@ public final class MCUtil { @@ -80,7 +80,7 @@ index 89e0181af99cba2368f875fc192342efc972f2ef..b3516862d796c2d9fcc1c67a60734454 chunkData.addProperty("queued-for-unload", chunkMap.toDrop.contains(playerChunk.pos.longKey)); chunkData.addProperty("status", status == null ? "unloaded" : status.toString()); diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b500140aa16 100644 +index 71af341580f08c71f4c4e6c758955cad14e7530d..af0a36071b4cf1ec77839eb8aa8f33917148d5e1 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -60,7 +60,7 @@ public class ChunkHolder { @@ -100,7 +100,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 boolean isUpdateQueued = false; // Paper private final ChunkMap chunkMap; // Paper -@@ -437,12 +438,18 @@ public class ChunkHolder { +@@ -444,12 +445,18 @@ public class ChunkHolder { }); } @@ -119,7 +119,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel); ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel); boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE; -@@ -453,9 +460,22 @@ public class ChunkHolder { +@@ -460,9 +467,22 @@ public class ChunkHolder { // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. if (playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !playerchunk_state1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { @@ -143,7 +143,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag. // These actions may however happen deferred, so we manually set the needsSaving flag already here. -@@ -512,12 +532,14 @@ public class ChunkHolder { +@@ -519,12 +539,14 @@ public class ChunkHolder { this.scheduleFullChunkPromotion(chunkStorage, this.fullChunkFuture, executor, ChunkHolder.FullChunkStatus.BORDER); // Paper start - cache ticking ready status this.fullChunkFuture.thenAccept(either -> { @@ -158,7 +158,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 } }); this.updateChunkToSave(this.fullChunkFuture, "full"); -@@ -538,6 +560,7 @@ public class ChunkHolder { +@@ -545,6 +567,7 @@ public class ChunkHolder { this.scheduleFullChunkPromotion(chunkStorage, this.tickingChunkFuture, executor, ChunkHolder.FullChunkStatus.TICKING); // Paper start - cache ticking ready status this.tickingChunkFuture.thenAccept(either -> { @@ -166,7 +166,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 either.ifLeft(chunk -> { // note: Here is a very good place to add callbacks to logic waiting on this. ChunkHolder.this.isTickingReady = true; -@@ -573,6 +596,7 @@ public class ChunkHolder { +@@ -580,6 +603,7 @@ public class ChunkHolder { this.scheduleFullChunkPromotion(chunkStorage, this.entityTickingChunkFuture, executor, ChunkHolder.FullChunkStatus.ENTITY_TICKING); // Paper start - cache ticking ready status this.entityTickingChunkFuture.thenAccept(either -> { @@ -174,7 +174,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 either.ifLeft(chunk -> { ChunkHolder.this.isEntityTickingReady = true; // Paper start - entity ticking chunk set -@@ -599,16 +623,45 @@ public class ChunkHolder { +@@ -606,16 +630,45 @@ public class ChunkHolder { this.demoteFullChunk(chunkStorage, playerchunk_state1); } @@ -223,7 +223,7 @@ index 05d2790b80a6d2e1dc6b8d2375f783be4eff2343..6ba7e2713452c4c6f48a1a825ef27b50 }); } }).exceptionally((throwable) -> { -@@ -733,7 +786,134 @@ public class ChunkHolder { +@@ -740,7 +793,134 @@ public class ChunkHolder { }; } @@ -711,10 +711,10 @@ index 211566dada0f820af331695b4c62035b89f25a53..d2865ce0523b74aaa935db72c6f34788 Ticket ticket = new Ticket<>(TicketType.FORCED, 31, pos); long i = pos.toLong(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e611c5369d9 100644 +index 9079e469161098e1520f6b9fd963adedd500024b..d0170f92335b331d6904e8c27e75f97efc7875c7 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -597,6 +597,26 @@ public class ServerChunkCache extends ChunkSource { +@@ -589,6 +589,26 @@ public class ServerChunkCache extends ChunkSource { return CompletableFuture.completedFuture(either); }, this.mainThreadProcessor); } @@ -741,7 +741,7 @@ index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e61 // Paper end - async chunk io @Nullable -@@ -637,6 +657,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -629,6 +649,8 @@ public class ServerChunkCache extends ChunkSource { Objects.requireNonNull(completablefuture); if (!completablefuture.isDone()) { // Paper // Paper start - async chunk io/loading @@ -750,7 +750,7 @@ index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e61 this.level.asyncChunkTaskManager.raisePriority(x1, z1, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY); com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.level, x1, z1); // Paper end -@@ -645,6 +667,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -637,6 +659,8 @@ public class ServerChunkCache extends ChunkSource { chunkproviderserver_b.managedBlock(completablefuture::isDone); com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug this.level.timings.syncChunkLoad.stopTiming(); // Paper @@ -759,7 +759,7 @@ index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e61 } // Paper ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; -@@ -718,10 +742,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -710,10 +734,12 @@ public class ServerChunkCache extends ChunkSource { if (create && !currentlyUnloading) { // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); @@ -772,7 +772,7 @@ index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e61 this.runDistanceManagerUpdates(); playerchunk = this.getVisibleChunkIfPresent(k); gameprofilerfiller.pop(); -@@ -731,7 +757,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -723,7 +749,13 @@ public class ServerChunkCache extends ChunkSource { } } @@ -787,7 +787,7 @@ index 9fdd2a39e3590b3098fa31b9b0e0081160819630..1b81ae617a43aa4723a879c150ce8e61 } private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) { -@@ -783,6 +815,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -775,6 +807,7 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -1177,7 +1177,7 @@ index dc95aaa62220f2042e287c7d0d69753b8e891fba..06577d9cd276e65f2fdf5082b9ee4dc2 org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isUnsaved()); server.getPluginManager().callEvent(unloadEvent); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index a5c335715a25dc154682e38a49ff308f30b41216..220db41f348437ae2d703ebae883e882804e6797 100644 +index 68f6ccacacad0e06f27d56b19b9f68b0691e747e..b61a53af941946a07f8bbd34f53191f3de23f927 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1992,6 +1992,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0503-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch b/patches/server/0503-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch index 542c802f1..57d50efae 100644 --- a/patches/server/0503-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch +++ b/patches/server/0503-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Don't mark dirty in invalid locations (SPIGOT-6086) diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index cd4328bd606d778ebb45f36af8cf23d88edef881..7407fd045c2f2d5934fb67028633575041ed7930 100644 +index dd073d97d21eaa15b004cfe3929b4bf20d16d266..0d9fbdb23d28a4082c71275ca00e42f3bcb31926 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -238,6 +238,7 @@ public class ChunkHolder { +@@ -245,6 +245,7 @@ public class ChunkHolder { } public void blockChanged(BlockPos pos) { diff --git a/patches/server/0726-Do-not-allow-the-server-to-unload-chunks-at-request-.patch b/patches/server/0726-Do-not-allow-the-server-to-unload-chunks-at-request-.patch index d2c7c618d..a5d388d19 100644 --- a/patches/server/0726-Do-not-allow-the-server-to-unload-chunks-at-request-.patch +++ b/patches/server/0726-Do-not-allow-the-server-to-unload-chunks-at-request-.patch @@ -10,10 +10,10 @@ to be unloaded will simply be unloaded next tick, rather than immediately. diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 1b81ae617a43aa4723a879c150ce8e611c5369d9..c97692440f4f0403714cdd7d1fba5496e324b40c 100644 +index d0170f92335b331d6904e8c27e75f97efc7875c7..b338abc1bd96e1bb5e90ed7594504c4e41f94eff 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -880,6 +880,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -872,6 +872,7 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - modelled on below public void purgeUnload() { diff --git a/patches/server/0728-Correctly-handle-recursion-for-chunkholder-updates.patch b/patches/server/0728-Correctly-handle-recursion-for-chunkholder-updates.patch index 48e805996..3d7be82a0 100644 --- a/patches/server/0728-Correctly-handle-recursion-for-chunkholder-updates.patch +++ b/patches/server/0728-Correctly-handle-recursion-for-chunkholder-updates.patch @@ -8,10 +8,10 @@ cause a recursive call which would handle the increase but then the caller would think the chunk would be unloaded. diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 7407fd045c2f2d5934fb67028633575041ed7930..6f7794a6e5c832328ddc16ca9b76414ea08020ad 100644 +index 0d9fbdb23d28a4082c71275ca00e42f3bcb31926..dbae93f9c6358ef61c6b1f29860e9905a4b74332 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -456,8 +456,10 @@ public class ChunkHolder { +@@ -463,8 +463,10 @@ public class ChunkHolder { playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state); } @@ -22,7 +22,7 @@ index 7407fd045c2f2d5934fb67028633575041ed7930..6f7794a6e5c832328ddc16ca9b76414e ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel); ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel); boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE; -@@ -499,6 +501,12 @@ public class ChunkHolder { +@@ -506,6 +508,12 @@ public class ChunkHolder { // Run callback right away if the future was already done chunkStorage.callbackExecutor.run(); diff --git a/patches/server/0731-Do-not-allow-ticket-level-changes-while-unloading-pl.patch b/patches/server/0731-Do-not-allow-ticket-level-changes-while-unloading-pl.patch index a1d6ef420..3dc1dc9d4 100644 --- a/patches/server/0731-Do-not-allow-ticket-level-changes-while-unloading-pl.patch +++ b/patches/server/0731-Do-not-allow-ticket-level-changes-while-unloading-pl.patch @@ -49,10 +49,10 @@ index 971a31641ec33a80f45e507944fa4cd90bfc466a..5d60fa26e9f5d3c9c57a61c509d5b924 } }; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index c97692440f4f0403714cdd7d1fba5496e324b40c..718c89f421637d623a92e5167397870562593a04 100644 +index b338abc1bd96e1bb5e90ed7594504c4e41f94eff..4b4952d632845fad5dd61c345dc5dba79a7ee209 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -816,6 +816,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -808,6 +808,7 @@ public class ServerChunkCache extends ChunkSource { public boolean runDistanceManagerUpdates() { if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority diff --git a/patches/server/0732-Do-not-allow-ticket-level-changes-when-updating-chun.patch b/patches/server/0732-Do-not-allow-ticket-level-changes-when-updating-chun.patch index d0f51016f..ab433784a 100644 --- a/patches/server/0732-Do-not-allow-ticket-level-changes-when-updating-chun.patch +++ b/patches/server/0732-Do-not-allow-ticket-level-changes-when-updating-chun.patch @@ -8,10 +8,10 @@ This WILL cause state corruption if it happens. So, don't allow it. diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 6f7794a6e5c832328ddc16ca9b76414ea08020ad..fbfbe9adeca7364e6346c887616890bf968f38a1 100644 +index dbae93f9c6358ef61c6b1f29860e9905a4b74332..b9d3535dd4e0af771bb74c85f18265e38f383e0e 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -436,7 +436,13 @@ public class ChunkHolder { +@@ -443,7 +443,13 @@ public class ChunkHolder { CompletableFuture completablefuture1 = new CompletableFuture(); completablefuture1.thenRunAsync(() -> { @@ -25,7 +25,7 @@ index 6f7794a6e5c832328ddc16ca9b76414ea08020ad..fbfbe9adeca7364e6346c887616890bf }, executor); this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((either) -> { -@@ -453,7 +459,12 @@ public class ChunkHolder { +@@ -460,7 +466,12 @@ public class ChunkHolder { private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) { this.pendingFullStateConfirmation.cancel(false); diff --git a/patches/server/0736-Prevent-unload-calls-removing-tickets-for-sync-loads.patch b/patches/server/0736-Prevent-unload-calls-removing-tickets-for-sync-loads.patch index e2c441623..000406a8b 100644 --- a/patches/server/0736-Prevent-unload-calls-removing-tickets-for-sync-loads.patch +++ b/patches/server/0736-Prevent-unload-calls-removing-tickets-for-sync-loads.patch @@ -18,10 +18,10 @@ index d2865ce0523b74aaa935db72c6f3478894e13408..ea4e46c113d3f0a5db6c891021e2e4c5 while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 718c89f421637d623a92e5167397870562593a04..adab778c11ef11cb57418675a98129afb01ec06e 100644 +index 4b4952d632845fad5dd61c345dc5dba79a7ee209..eca75916c5e476db280e58522e5540def4f4de68 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -721,6 +721,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -713,6 +713,8 @@ public class ServerChunkCache extends ChunkSource { return completablefuture; } @@ -30,7 +30,7 @@ index 718c89f421637d623a92e5167397870562593a04..adab778c11ef11cb57418675a98129af private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper start - add isUrgent - old sig left in place for dirty nms plugins return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false); -@@ -739,9 +741,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -731,9 +733,12 @@ public class ServerChunkCache extends ChunkSource { ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel()); currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)); } @@ -43,7 +43,7 @@ index 718c89f421637d623a92e5167397870562593a04..adab778c11ef11cb57418675a98129af if (isUrgent) this.distanceManager.markUrgent(chunkcoordintpair); // Paper - Chunk priority if (this.chunkAbsent(playerchunk, l)) { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -752,13 +757,21 @@ public class ServerChunkCache extends ChunkSource { +@@ -744,13 +749,21 @@ public class ServerChunkCache extends ChunkSource { playerchunk = this.getVisibleChunkIfPresent(k); gameprofilerfiller.pop(); if (this.chunkAbsent(playerchunk, l)) { diff --git a/patches/server/0742-Optimise-chunk-tick-iteration.patch b/patches/server/0742-Optimise-chunk-tick-iteration.patch index 6d81aa873..136af3f2a 100644 --- a/patches/server/0742-Optimise-chunk-tick-iteration.patch +++ b/patches/server/0742-Optimise-chunk-tick-iteration.patch @@ -6,7 +6,7 @@ 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 fbfbe9adeca7364e6346c887616890bf968f38a1..bd43fbc8a93afa7604aa467392520ed7b30a1d83 100644 +index b9d3535dd4e0af771bb74c85f18265e38f383e0e..469b921cceabc3f42961e8aa5314bdc849ad41b9 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -86,11 +86,21 @@ public class ChunkHolder { @@ -31,7 +31,7 @@ index fbfbe9adeca7364e6346c887616890bf968f38a1..bd43fbc8a93afa7604aa467392520ed7 } // Paper end - optimise anyPlayerCloseEnoughForSpawning long lastAutoSaveTime; // Paper - incremental autosave -@@ -246,7 +256,7 @@ public class ChunkHolder { +@@ -253,7 +263,7 @@ public class ChunkHolder { if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 if (this.changedBlocksPerSection[i] == null) { @@ -40,7 +40,7 @@ index fbfbe9adeca7364e6346c887616890bf968f38a1..bd43fbc8a93afa7604aa467392520ed7 this.changedBlocksPerSection[i] = new ShortOpenHashSet(); } -@@ -266,6 +276,7 @@ public class ChunkHolder { +@@ -273,6 +283,7 @@ public class ChunkHolder { int k = this.lightEngine.getMaxLightSection(); if (y >= j && y <= k) { @@ -48,7 +48,7 @@ index fbfbe9adeca7364e6346c887616890bf968f38a1..bd43fbc8a93afa7604aa467392520ed7 int l = y - j; if (lightType == LightLayer.SKY) { -@@ -279,8 +290,19 @@ public class ChunkHolder { +@@ -286,8 +297,19 @@ public class ChunkHolder { } } @@ -82,7 +82,7 @@ index 5d60fa26e9f5d3c9c57a61c509d5b924bbed3281..ef28e0f57ba593265a3eca4d3f21d0b1 // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() public final CallbackExecutor callbackExecutor = new CallbackExecutor(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index adab778c11ef11cb57418675a98129afb01ec06e..d5eb5a365c8e8cdcd8e9cf54918cc2fb383c6625 100644 +index eca75916c5e476db280e58522e5540def4f4de68..d06ad4f2c76eebd3b8191f3de6c0199fa3bb5f22 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -46,6 +46,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana @@ -93,7 +93,7 @@ index adab778c11ef11cb57418675a98129afb01ec06e..d5eb5a365c8e8cdcd8e9cf54918cc2fb public class ServerChunkCache extends ChunkSource { -@@ -994,34 +995,42 @@ public class ServerChunkCache extends ChunkSource { +@@ -986,34 +987,42 @@ public class ServerChunkCache extends ChunkSource { this.lastSpawnState = spawnercreature_d; gameprofilerfiller.popPush("filteringLoadedChunks"); @@ -152,7 +152,7 @@ index adab778c11ef11cb57418675a98129afb01ec06e..d5eb5a365c8e8cdcd8e9cf54918cc2fb NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); } -@@ -1029,7 +1038,16 @@ public class ServerChunkCache extends ChunkSource { +@@ -1021,7 +1030,16 @@ public class ServerChunkCache extends ChunkSource { this.level.tickChunk(chunk1, k); } } @@ -169,7 +169,7 @@ index adab778c11ef11cb57418675a98129afb01ec06e..d5eb5a365c8e8cdcd8e9cf54918cc2fb this.level.timings.chunkTicks.stopTiming(); // Paper gameprofilerfiller.popPush("customSpawners"); if (flag2) { -@@ -1037,15 +1055,24 @@ public class ServerChunkCache extends ChunkSource { +@@ -1029,15 +1047,24 @@ public class ServerChunkCache extends ChunkSource { this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); } // Paper - timings } @@ -188,7 +188,7 @@ index adab778c11ef11cb57418675a98129afb01ec06e..d5eb5a365c8e8cdcd8e9cf54918cc2fb + ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); + this.chunkMap.needsChangeBroadcasting.clear(); + for (ChunkHolder holder : copy) { -+ holder.broadcastChanges(holder.getFullChunkUnchecked()); // LevelChunks are NEVER unloaded ++ holder.broadcastChanges(holder.getFullChunkNowUnchecked()); // LevelChunks are NEVER unloaded + if (holder.needsBroadcastChanges()) { + // I DON'T want to KNOW what DUMB plugins might be doing. + this.chunkMap.needsChangeBroadcasting.add(holder); diff --git a/patches/server/0743-Execute-chunk-tasks-mid-tick.patch b/patches/server/0743-Execute-chunk-tasks-mid-tick.patch index acf3980fc..2720681ef 100644 --- a/patches/server/0743-Execute-chunk-tasks-mid-tick.patch +++ b/patches/server/0743-Execute-chunk-tasks-mid-tick.patch @@ -19,7 +19,7 @@ index b27021a42cbed3f0648a8d0903d00d03922ae221..eada966d7f108a6081be7a848f5c1dfc private MinecraftTimings() {} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 65d5d96a687712d87bbc61d85f80438811bae07d..a279368fe144bd41d15e5fe5e565412f8b4ef9f7 100644 +index 8aaf73d24ddff65c45eeb18d573e20fb8a1439a5..fddb279d161b30d6944495f0de9f6b7e21761a80 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1344,6 +1344,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entry = (Entry) objectbidirectionaliterator.next(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 2b8352e74f46e397a6f5b27c300153fde7c56af7..a8c3c76ec3aed40655a0c5335407cb20ecfbc63d 100644 +index df986f97b86ba1fa4da15d969c635333abfdba91..6e10ca6dec598032eb8dc20dd88876db2ba2ae9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -160,7 +160,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -219,12 +219,12 @@ index 2b8352e74f46e397a6f5b27c300153fde7c56af7..a8c3c76ec3aed40655a0c5335407cb20 + synchronized (world.getChunkSource().chunkMap.updatingChunks) { + chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap().clone(); + } -+ return chunks.values().stream().map(ChunkHolder::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); ++ return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); + // Paper end - change updating chunks map + } + // Paper end -+ Long2ObjectLinkedOpenHashMap chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map - return chunks.values().stream().map(ChunkHolder::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); ++ Long2ObjectLinkedOpenHashMap chunks = this.world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map + return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); } @@ -430,7 +441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0749-Distance-manager-tick-timings.patch b/patches/server/0749-Distance-manager-tick-timings.patch index 69c8bf095..2ea652c2a 100644 --- a/patches/server/0749-Distance-manager-tick-timings.patch +++ b/patches/server/0749-Distance-manager-tick-timings.patch @@ -19,10 +19,10 @@ index eada966d7f108a6081be7a848f5c1dfcb1eed676..a977f7483f37df473096b2234dc1308b public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks"); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index b73f49b9bf49dc2a08aa8ffece675df41c077412..5271cc135e636961fc1248f6b98bb122ab3391e6 100644 +index e14215d538d19838041e3e21a84396c2f31ecd8e..84f386e5f15d956cfd279baecd01558dcf9af88d 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -831,6 +831,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -823,6 +823,7 @@ public class ServerChunkCache extends ChunkSource { public boolean runDistanceManagerUpdates() { if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority if (this.chunkMap.unloadingPlayerChunk) { LOGGER.error("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper @@ -30,7 +30,7 @@ index b73f49b9bf49dc2a08aa8ffece675df41c077412..5271cc135e636961fc1248f6b98bb122 boolean flag = this.distanceManager.runAllUpdates(this.chunkMap); boolean flag1 = this.chunkMap.promoteChunkMap(); -@@ -840,6 +841,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -832,6 +833,7 @@ public class ServerChunkCache extends ChunkSource { this.clearCache(); return true; } diff --git a/patches/server/0756-Consolidate-flush-calls-for-entity-tracker-packets.patch b/patches/server/0756-Consolidate-flush-calls-for-entity-tracker-packets.patch index 4669941fb..73b641787 100644 --- a/patches/server/0756-Consolidate-flush-calls-for-entity-tracker-packets.patch +++ b/patches/server/0756-Consolidate-flush-calls-for-entity-tracker-packets.patch @@ -22,10 +22,10 @@ With this change I could get all 200 on at 0ms ping. So in general this patch should reduce Netty I/O thread load. diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 5271cc135e636961fc1248f6b98bb122ab3391e6..cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f 100644 +index 84f386e5f15d956cfd279baecd01558dcf9af88d..78538e3d3468f5c682cf4123ac930796c20af60c 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -1077,7 +1077,24 @@ public class ServerChunkCache extends ChunkSource { +@@ -1069,7 +1069,24 @@ public class ServerChunkCache extends ChunkSource { this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing gameprofilerfiller.pop(); // Paper end - use set of chunks requiring updates, rather than iterating every single one loaded diff --git a/patches/server/0766-Optimise-nearby-player-lookups.patch b/patches/server/0766-Optimise-nearby-player-lookups.patch index ac5756d26..57d070755 100644 --- a/patches/server/0766-Optimise-nearby-player-lookups.patch +++ b/patches/server/0766-Optimise-nearby-player-lookups.patch @@ -9,7 +9,7 @@ since the penalty of a map lookup could outweigh the benefits of searching less players (as it basically did in the outside range patch). diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index bd43fbc8a93afa7604aa467392520ed7b30a1d83..1a7fc533afced7235162f81b2de8148cef05414a 100644 +index 469b921cceabc3f42961e8aa5314bdc849ad41b9..09616415e8f11d40435dc81282b818ac9cbbdcbe 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -91,6 +91,12 @@ public class ChunkHolder { @@ -17,7 +17,7 @@ index bd43fbc8a93afa7604aa467392520ed7b30a1d83..1a7fc533afced7235162f81b2de8148c } // Paper end - optimise chunk tick iteration + // Paper start - optimise checkDespawn -+ LevelChunk chunk = this.getFullChunkUnchecked(); ++ LevelChunk chunk = this.getFullChunkNowUnchecked(); + if (chunk != null) { + chunk.updateGeneralAreaCache(); + } @@ -30,7 +30,7 @@ index bd43fbc8a93afa7604aa467392520ed7b30a1d83..1a7fc533afced7235162f81b2de8148c } // Paper end - optimise chunk tick iteration + // Paper start - optimise checkDespawn -+ LevelChunk chunk = this.getFullChunkUnchecked(); ++ LevelChunk chunk = this.getFullChunkNowUnchecked(); + if (chunk != null) { + chunk.removeGeneralAreaCache(); + } @@ -105,7 +105,7 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5 protected ChunkGenerator generator() { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 6dee3e414e378538e6b5ef93dc1414e0128cffbb..ea665ae89b0963e5605ff0bc87f906fdddeb2c9a 100644 +index 6b90582dd0aefccab7e1b5a1718f96854d1cdd81..c780af51c50c019e7fa0e5aee3d05e3374f79948 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -400,6 +400,83 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/0858-Replace-player-chunk-loader-system.patch b/patches/server/0858-Replace-player-chunk-loader-system.patch index a23dcdd0a..46d7fd489 100644 --- a/patches/server/0858-Replace-player-chunk-loader-system.patch +++ b/patches/server/0858-Replace-player-chunk-loader-system.patch @@ -1290,7 +1290,7 @@ index 42400b6f0b693dd0ec4a2303a82bd131753a24ba..9bbf990212ee55a267d0eb1e863618c5 // Paper end diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index b61abf227a04b4565c2525e5f469db30c3a545a5..7bddc7517356cc74104dcc5c7c55522a53f2596f 100644 +index 63294b95ec062e32c87e52560353374db430cbe5..6aec679e75aa6655b47a552db011924ea3a6c922 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -647,7 +647,8 @@ public final class MCUtil { @@ -1304,7 +1304,7 @@ index b61abf227a04b4565c2525e5f469db30c3a545a5..7bddc7517356cc74104dcc5c7c55522a worldData.addProperty("keep-spawn-loaded-range", world.paperConfig.keepLoadedRange); worldData.addProperty("visible-chunk-count", visibleChunks.size()); diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 36b6e7295cf7484675c8c2b9624c1f6fea7aed1d..38db3905f47fefb5c958fa24aef2313eae68753c 100644 +index d061dc4b5de6b629d6ddcdbfe9ca652dfcec8952..2ebaff03052d800d3dad05bbf67729b02bd3262a 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -76,6 +76,17 @@ public class ChunkHolder { @@ -1325,7 +1325,7 @@ index 36b6e7295cf7484675c8c2b9624c1f6fea7aed1d..38db3905f47fefb5c958fa24aef2313e // Paper start - optimise anyPlayerCloseEnoughForSpawning // cached here to avoid a map lookup -@@ -261,7 +272,7 @@ public class ChunkHolder { +@@ -268,7 +279,7 @@ public class ChunkHolder { public void blockChanged(BlockPos pos) { if (!pos.isInsideBuildHeightAndWorldBoundsHorizontal(levelHeightAccessor)) return; // Paper - SPIGOT-6086 for all invalid locations; avoid acquiring locks @@ -1334,7 +1334,7 @@ index 36b6e7295cf7484675c8c2b9624c1f6fea7aed1d..38db3905f47fefb5c958fa24aef2313e if (chunk != null) { int i = this.levelHeightAccessor.getSectionIndex(pos.getY()); -@@ -277,11 +288,11 @@ public class ChunkHolder { +@@ -284,11 +295,11 @@ public class ChunkHolder { } public void sectionLightChanged(LightLayer lightType, int y) { @@ -1348,7 +1348,7 @@ index 36b6e7295cf7484675c8c2b9624c1f6fea7aed1d..38db3905f47fefb5c958fa24aef2313e if (chunk1 != null) { int j = this.lightEngine.getMinLightSection(); -@@ -383,9 +394,28 @@ public class ChunkHolder { +@@ -390,9 +401,28 @@ public class ChunkHolder { } public void broadcast(Packet packet, boolean onlyOnWatchDistanceEdge) { @@ -1816,10 +1816,10 @@ index b22c771ca35466574d5a73f2da3fc8762cb29487..3542b8b347b9a142c53f300251a05a11 + */ // Paper - replace old loader system } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f..5793154c0deca7fc570bbe858c6bea0d640db941 100644 +index 78538e3d3468f5c682cf4123ac930796c20af60c..fb0757d4bb32123641535a88a22bc074b8d2623f 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -851,17 +851,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -843,17 +843,10 @@ public class ServerChunkCache extends ChunkSource { // Paper end public boolean isPositionTicking(long pos) { @@ -1841,7 +1841,7 @@ index cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f..5793154c0deca7fc570bbe858c6bea0d } public void save(boolean flush) { -@@ -918,6 +911,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -910,6 +903,7 @@ public class ServerChunkCache extends ChunkSource { this.level.getProfiler().popPush("chunks"); if (tickChunks) { this.level.timings.chunks.startTiming(); // Paper - timings @@ -1849,7 +1849,7 @@ index cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f..5793154c0deca7fc570bbe858c6bea0d this.tickChunks(); this.level.timings.chunks.stopTiming(); // Paper - timings } -@@ -1031,13 +1025,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -1023,13 +1017,13 @@ public class ServerChunkCache extends ChunkSource { // Paper end - optimise chunk tick iteration ChunkPos chunkcoordintpair = chunk1.getPos(); @@ -1865,7 +1865,7 @@ index cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f..5793154c0deca7fc570bbe858c6bea0d this.level.tickChunk(chunk1, k); if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper } -@@ -1262,6 +1256,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1254,6 +1248,7 @@ public class ServerChunkCache extends ChunkSource { public boolean pollTask() { try { boolean execChunkTask = com.destroystokyo.paper.io.chunk.ChunkTaskManager.pollChunkWaitQueue() || ServerChunkCache.this.level.asyncChunkTaskManager.pollNextChunkTask(); // Paper @@ -1874,7 +1874,7 @@ index cd6eb305f4d36be923f6c5f0dd85e449d0f94c8f..5793154c0deca7fc570bbe858c6bea0d return true; } else { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 1e2c430a8df6afde91e3c5169d2d7b501acdec7f..1347ea594d3e771f02a73d95454388d4533c8be8 100644 +index 46db8458478de3dee83fc03478245ba914c79999..5bc0feaa6a86f11027896aed11d21e568dd4c8ce 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -658,7 +658,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2098,7 +2098,7 @@ index b46648301396930478391967b371bf8d201901e1..c8fb4b2bc86c9aa2e7c2e9ee10208cf9 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 7e8be67b85fc28ecf9d27241e1a7157b976885a5..a3ddeb9862bc87294c215dc906cd8cca8f699b62 100644 +index b3dff7979aeec8ff4eff1233b551023309f580ae..f807ee757488f05be626643e009eac95245b3af1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -2218,43 +2218,56 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0885-Fix-generator-settings-string-for-flat-type-worlds.patch b/patches/server/0885-Fix-generator-settings-string-for-flat-type-worlds.patch deleted file mode 100644 index 4518e7553..000000000 --- a/patches/server/0885-Fix-generator-settings-string-for-flat-type-worlds.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Wed, 9 Mar 2022 12:51:29 -0800 -Subject: [PATCH] Fix generator settings string for flat-type worlds - -Fixes MC-195468 - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -index 3f46bf0358fd9bb4d0fa41026f138ffd21952bde..3ef58c932cc0a34cc6f0e0297ed91fd260101efc 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -@@ -196,7 +196,7 @@ public class WorldGenSettings { - String var8 = worldGenProperties.levelType(); - switch(var8) { - case "flat": -- Dynamic dynamic = new Dynamic<>(JsonOps.INSTANCE, worldGenProperties.generatorSettings()); -+ Dynamic dynamic = new Dynamic<>(net.minecraft.resources.RegistryOps.create(JsonOps.INSTANCE, registryManager), worldGenProperties.generatorSettings()); // Paper - needs RegistryOps to access biome registry inside FlatLevelGeneratorSettings's Codec, Fixes MC-195468 - return new WorldGenSettings(l, worldGenProperties.generateStructures(), false, withOverworld(registry, registry4, new FlatLevelSource(registry3, FlatLevelGeneratorSettings.CODEC.parse(dynamic).resultOrPartial(LOGGER::error).orElseGet(() -> { - return FlatLevelGeneratorSettings.getDefault(registry2, registry3); - })))); diff --git a/patches/server/0886-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch b/patches/server/0885-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch similarity index 100% rename from patches/server/0886-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch rename to patches/server/0885-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch diff --git a/work/Bukkit b/work/Bukkit index 33a2b476b..7902647a6 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 33a2b476bbde7c2c0c45e644dc99b10d65736d40 +Subproject commit 7902647a668318b7e04f817e07ae9b955d7c0485 diff --git a/work/CraftBukkit b/work/CraftBukkit index e9f972d67..10922194f 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit e9f972d6744d66460a78a868d298c7f543533073 +Subproject commit 10922194f43009dea660c8b5c9fe27f136e940a6