From af62c96f5547b38339c650f0d88e9873369dd2e0 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:17:18 +0800 Subject: [PATCH] Fix PWT diff --- ...-SparklyPaper-Parallel-world-ticking.patch | 29 ++++++++++++------- .../0212-Use-BFS-on-getSlopeDistance.patch | 4 +-- ...-Micro-optimizations-for-random-tick.patch | 6 ++-- .../features/0252-optimize-mob-spawning.patch | 18 ++++++------ .../features/0259-optimize-random-tick.patch | 8 ++--- .../features/0265-Paw-optimization.patch | 6 ++-- ...Paper-PR-Optimise-temptation-lookups.patch | 4 +-- 7 files changed, 42 insertions(+), 33 deletions(-) diff --git a/leaf-server/minecraft-patches/features/0207-SparklyPaper-Parallel-world-ticking.patch b/leaf-server/minecraft-patches/features/0207-SparklyPaper-Parallel-world-ticking.patch index dc2462b7..4ea83872 100644 --- a/leaf-server/minecraft-patches/features/0207-SparklyPaper-Parallel-world-ticking.patch +++ b/leaf-server/minecraft-patches/features/0207-SparklyPaper-Parallel-world-ticking.patch @@ -411,20 +411,19 @@ index 77f11179836636424927843f5f10c3fd23d2b2d4..9b8d119116b0c3a51d3fe2ff7efb33cc // Gale start - Pufferfish - SIMD support diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 8f41326fda8c5f9f6926038508be6c6529b051bc..46e171ca454253c32e22c0c18587e9a7ba19f331 100644 +index 8f41326fda8c5f9f6926038508be6c6529b051bc..f76da1dc0874493ce71fce19e02e68da5f3ff50d 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -175,7 +175,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -175,6 +175,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon // call mid-tick tasks for chunk system if ((i & 7) == 0) { -- ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); -+ //((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); // SparklyPaper - parallel world ticking (only run mid-tick at the end of each tick / fixes concurrency bugs related to executeMidTickTasks) ++ if (!org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // SparklyPaper - parallel world ticking (only run mid-tick at the end of each tick / fixes concurrency bugs related to executeMidTickTasks) // Leaf start - SparklyPaper - parallel world ticking mod (make configurable) + ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); continue; } - } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 91752678f887559132921cff61697478e5f44e3d..0b26940e3f1645b6b8d5bd92be4d10fbe17fda58 100644 +index 91752678f887559132921cff61697478e5f44e3d..42d7a205717762af03af48ba7a0606a19cb35606 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -180,7 +180,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -610,7 +609,17 @@ index 91752678f887559132921cff61697478e5f44e3d..0b26940e3f1645b6b8d5bd92be4d10fb int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.purpurConfig.playersSkipNight && this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { // Purpur - Config for skipping night // Paper start - create time skip event - move up calculations -@@ -1311,9 +1444,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -831,7 +964,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); + // Paper end - Prevent block entity and entity crashes + } +- this.moonrise$midTickTasks(); // Paper - rewrite chunk system ++ if (!org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // SparklyPaper - parallel world ticking (only run mid-tick at the end of each tick / fixes concurrency bugs related to executeMidTickTasks) // Leaf start - SparklyPaper - parallel world ticking mod (make configurable) ++ this.moonrise$midTickTasks(); // Paper - rewrite chunk system + // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick + } + } +@@ -1311,9 +1445,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe fluidState.tick(this, pos, blockState); } // Paper start - rewrite chunk system @@ -625,7 +634,7 @@ index 91752678f887559132921cff61697478e5f44e3d..0b26940e3f1645b6b8d5bd92be4d10fb // Paper end - rewrite chunk system } -@@ -1324,9 +1460,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1324,9 +1461,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe blockState.tick(this, pos, this.random); } // Paper start - rewrite chunk system @@ -640,7 +649,7 @@ index 91752678f887559132921cff61697478e5f44e3d..0b26940e3f1645b6b8d5bd92be4d10fb // Paper end - rewrite chunk system } -@@ -1591,6 +1730,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1591,6 +1731,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } private void addPlayer(ServerPlayer player) { @@ -649,7 +658,7 @@ index 91752678f887559132921cff61697478e5f44e3d..0b26940e3f1645b6b8d5bd92be4d10fb Entity entity = this.getEntity(player.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID()); -@@ -1603,7 +1744,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1603,7 +1745,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit start private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { diff --git a/leaf-server/minecraft-patches/features/0212-Use-BFS-on-getSlopeDistance.patch b/leaf-server/minecraft-patches/features/0212-Use-BFS-on-getSlopeDistance.patch index 17024913..f3bac9cc 100644 --- a/leaf-server/minecraft-patches/features/0212-Use-BFS-on-getSlopeDistance.patch +++ b/leaf-server/minecraft-patches/features/0212-Use-BFS-on-getSlopeDistance.patch @@ -9,10 +9,10 @@ Leaf: ~48ms (-36%) This should help drastically on the farms that use actively changing fluids. diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a4c7fd6214ff37d4eb52e42b021c24a13d6a15c9..9453d65fbe08911674cf9090d8729264429c8d8a 100644 +index 9b31e15392b38fd269559f69e8de56251aef6db7..dfeff3886bfeb3aa92e5961237ac0af89c78cb4e 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1443,6 +1443,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1444,6 +1444,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.emptyTime = 0; } diff --git a/leaf-server/minecraft-patches/features/0217-Micro-optimizations-for-random-tick.patch b/leaf-server/minecraft-patches/features/0217-Micro-optimizations-for-random-tick.patch index e0e666fe..a727324e 100644 --- a/leaf-server/minecraft-patches/features/0217-Micro-optimizations-for-random-tick.patch +++ b/leaf-server/minecraft-patches/features/0217-Micro-optimizations-for-random-tick.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Micro optimizations for random tick diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 9453d65fbe08911674cf9090d8729264429c8d8a..a1c2e9018800339fca62d95c522da1bf254568fe 100644 +index dfeff3886bfeb3aa92e5961237ac0af89c78cb4e..33e18114fdcc36df56156932d99f732b417887c0 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1041,7 +1041,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1042,7 +1042,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper start - optimise random ticking private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) { final LevelChunkSection[] sections = chunk.getSections(); @@ -17,7 +17,7 @@ index 9453d65fbe08911674cf9090d8729264429c8d8a..a1c2e9018800339fca62d95c522da1bf final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Leaf - Faster random generator - upcasting final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294(); -@@ -1050,41 +1050,41 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1051,41 +1051,41 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final int offsetZ = cpos.z << 4; for (int sectionIndex = 0, sectionsLen = sections.length; sectionIndex < sectionsLen; sectionIndex++) { diff --git a/leaf-server/minecraft-patches/features/0252-optimize-mob-spawning.patch b/leaf-server/minecraft-patches/features/0252-optimize-mob-spawning.patch index 1ee4020e..3a022492 100644 --- a/leaf-server/minecraft-patches/features/0252-optimize-mob-spawning.patch +++ b/leaf-server/minecraft-patches/features/0252-optimize-mob-spawning.patch @@ -26,7 +26,7 @@ index 5c369b3d94e369c3f240821ad90b9d96223f24ca..9803c395fce103cb7bc746f43a017ff9 } // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab9545627dd6 100644 +index f76da1dc0874493ce71fce19e02e68da5f3ff50d..8b9d7129da577d7b613c0e21ee075e68edef7b12 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -70,11 +70,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -43,7 +43,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 // Paper start public final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>(); public int getFullChunksCount() { -@@ -498,6 +498,23 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -499,6 +499,23 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } private void tickChunks() { @@ -67,7 +67,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 long gameTime = this.level.getGameTime(); long l = gameTime - this.lastInhabitedUpdate; this.lastInhabitedUpdate = gameTime; -@@ -511,8 +528,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -512,8 +529,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } // Pufferfish start - optimize mob spawning @@ -78,7 +78,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 // Paper start - per player mob spawning backoff for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) { player.mobCounts[ii] = 0; -@@ -524,34 +541,27 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -525,34 +542,27 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon player.mobBackoffCounts[ii] = newBackoff; } // Paper end - per player mob spawning backoff @@ -128,7 +128,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 _pufferfish_spawnCountsReady.set(true); }); } -@@ -610,6 +620,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -611,6 +621,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon chunkRange = Math.min(chunkRange, 8); entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange); entityPlayer.playerNaturallySpawnedEvent.callEvent(); @@ -136,7 +136,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 } // Paper end - PlayerNaturallySpawnCreaturesEvent boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -@@ -621,16 +632,36 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -622,16 +633,36 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon List list = this.spawningChunks; try { @@ -178,7 +178,7 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 list.clear(); } -@@ -648,7 +679,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -649,7 +680,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } if (!spawnCategories.isEmpty()) { @@ -188,10 +188,10 @@ index 46e171ca454253c32e22c0c18587e9a7ba19f331..517c50639175276a9a040abf09f3ab95 } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a1c2e9018800339fca62d95c522da1bf254568fe..e76718a4f6778694e57381f986fa60ae13216506 100644 +index 33e18114fdcc36df56156932d99f732b417887c0..e59b46a3c5912fb840f884f9aa9bb04ff46a6cc1 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1091,6 +1091,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1092,6 +1092,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.simpleRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking public final org.dreeam.leaf.world.DespawnMap despawnMap = new org.dreeam.leaf.world.DespawnMap(paperConfig()); // Leaf - optimize despawn diff --git a/leaf-server/minecraft-patches/features/0259-optimize-random-tick.patch b/leaf-server/minecraft-patches/features/0259-optimize-random-tick.patch index f20a0f93..af53b5ca 100644 --- a/leaf-server/minecraft-patches/features/0259-optimize-random-tick.patch +++ b/leaf-server/minecraft-patches/features/0259-optimize-random-tick.patch @@ -5,10 +5,10 @@ Subject: [PATCH] optimize random tick diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 517c50639175276a9a040abf09f3ab9545627dd6..b2ded00d09bdab9889515b4829744eedaa0b0aa0 100644 +index 8b9d7129da577d7b613c0e21ee075e68edef7b12..8d074d2adf36827bc7c38a5f4efe4771453631b8 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -665,7 +665,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -666,7 +666,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon list.clear(); } @@ -24,10 +24,10 @@ index 517c50639175276a9a040abf09f3ab9545627dd6..b2ded00d09bdab9889515b4829744eed this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index e76718a4f6778694e57381f986fa60ae13216506..5850662b69bb08d1169e3ef28c570b54a0475794 100644 +index e59b46a3c5912fb840f884f9aa9bb04ff46a6cc1..a16bd45a3fd9a8937a7624c8f7838367e7e087bd 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1092,6 +1092,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1093,6 +1093,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final org.dreeam.leaf.world.DespawnMap despawnMap = new org.dreeam.leaf.world.DespawnMap(paperConfig()); // Leaf - optimize despawn public final org.dreeam.leaf.world.NatureSpawnChunkMap natureSpawnChunkMap = new org.dreeam.leaf.world.NatureSpawnChunkMap(); // Leaf - optimize mob spawning diff --git a/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch b/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch index df61c2ae..62a0c1a3 100644 --- a/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch +++ b/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch @@ -100,10 +100,10 @@ index 4535858701b2bb232b9d2feb2af6551526232ddc..e65c62dbe4c1560ae153e4c4344e9194 - // Paper end - detailed watchdog information } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 5850662b69bb08d1169e3ef28c570b54a0475794..a474a8bdda00c1dbea30f0981e38ea6188b84c7a 100644 +index a16bd45a3fd9a8937a7624c8f7838367e7e087bd..2712a9bf21731a1cf575dcb4ece19e6f02271c12 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1495,13 +1495,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1496,13 +1496,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information public void tickNonPassenger(Entity entity) { @@ -117,7 +117,7 @@ index 5850662b69bb08d1169e3ef28c570b54a0475794..a474a8bdda00c1dbea30f0981e38ea61 entity.setOldPosAndRot(); entity.tickCount++; entity.totalEntityAge++; // Paper - age-like counter for all entities -@@ -1514,13 +1508,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1515,13 +1509,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (Entity entity1 : entity.getPassengers()) { this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 } diff --git a/leaf-server/minecraft-patches/features/0280-Paper-PR-Optimise-temptation-lookups.patch b/leaf-server/minecraft-patches/features/0280-Paper-PR-Optimise-temptation-lookups.patch index 4dc5e4a4..b20eb51c 100644 --- a/leaf-server/minecraft-patches/features/0280-Paper-PR-Optimise-temptation-lookups.patch +++ b/leaf-server/minecraft-patches/features/0280-Paper-PR-Optimise-temptation-lookups.patch @@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..5f5cdfc538ba9aa6666c019df6706015 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a474a8bdda00c1dbea30f0981e38ea6188b84c7a..f839c1b040f51e536b575ed5906f85a0a374b37f 100644 +index 2712a9bf21731a1cf575dcb4ece19e6f02271c12..8496069c8605bd0233efc9b76492b22be6fefcd9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -936,6 +936,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -128,7 +128,7 @@ index a474a8bdda00c1dbea30f0981e38ea6188b84c7a..f839c1b040f51e536b575ed5906f85a0 if (org.dreeam.leaf.config.modules.opt.OptimizeDespawn.enabled && tickRateManager.runsNormally()) { despawnMap.tick(this, this.entityTickList); } // Leaf - optimize despawn this.entityTickList -@@ -3038,4 +3039,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -3039,4 +3040,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.lagCompensationTick = (System.nanoTime() - MinecraftServer.SERVER_INIT) / (java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(50L)); } // Paper end - lag compensation