diff --git a/patches/server/0116-Skip-unnecessary-mob-spawning-computations.patch b/patches/server/0116-Skip-unnecessary-mob-spawning-computations.patch new file mode 100644 index 0000000..30595e4 --- /dev/null +++ b/patches/server/0116-Skip-unnecessary-mob-spawning-computations.patch @@ -0,0 +1,84 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sun, 25 Dec 2022 20:29:03 +0100 +Subject: [PATCH] Skip unnecessary mob spawning computations + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Only create a spawner state when we are actually spawning mobs" +By: PureGero +As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +index 8ed18a158a13dceca7cd342125c09e52ac0d013c..df4db98618c6c9261b4ec8e2987c4ed26af4bd4b 100644 +--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java ++++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +@@ -693,10 +693,15 @@ public class ServerChunkCache extends ChunkSource { + int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit + ++ // Gale start - MultiPaper - skip unnecessary mob spawning computations ++ NaturalSpawner.SpawnState spawnercreature_d; // moved down ++ boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit ++ boolean flag2AndHasNaturalSpawn = flag2 && this.anySpawnCategoryIsSpawnedThisTick(); ++ if (flag2AndHasNaturalSpawn) { ++ // Gale end - MultiPaper - skip unnecessary mob spawning computations + this.level.timings.countNaturalMobs.startTiming(); // Paper - timings + int l = this.distanceManager.getNaturalSpawnChunkCount(); + // Paper start - per player mob spawning +- NaturalSpawner.SpawnState spawnercreature_d; // moved down + if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't count mobs when animals and monsters are disabled + // re-set mob counts + for (ServerPlayer player : this.level.players) { +@@ -710,13 +715,16 @@ public class ServerChunkCache extends ChunkSource { + this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings + + this.lastSpawnState = spawnercreature_d; ++ // Gale start - MultiPaper - skip unnecessary mob spawning computations ++ } else { ++ spawnercreature_d = null; ++ } ++ // Gale end - MultiPaper - skip unnecessary mob spawning computations + // Paper - moved down + this.level.timings.chunkTicks.startTiming(); // Paper + + // Paper - moved down + +- boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit +- + // Paper - only shuffle if per-player mob spawning is disabled + // Paper - moved natural spawn event up + // Paper start - optimise chunk tick iteration +@@ -745,7 +753,7 @@ public class ServerChunkCache extends ChunkSource { + + if ((true || this.level.isNaturalSpawningAllowed(chunkcoordintpair)) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, false)) { // Paper - optimise anyPlayerCloseEnoughForSpawning // Paper - the chunk is known ticking + chunk1.incrementInhabitedTime(j); +- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration ++ if (flag2AndHasNaturalSpawn && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations + NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); + } + +@@ -806,6 +814,20 @@ public class ServerChunkCache extends ChunkSource { + } + } + ++ // Gale start - MultiPaper - skip unnecessary mob spawning computations ++ public boolean anySpawnCategoryIsSpawnedThisTick() { ++ long gameTime = this.level.getLevelData().getGameTime(); ++ ++ for (long ticksForSpawnCategory : this.level.ticksPerSpawnCategory.values()) { ++ if (ticksForSpawnCategory != 0L && gameTime % ticksForSpawnCategory == 0L) { ++ return true; ++ } ++ } ++ ++ return false; ++ } ++ // Gale end - MultiPaper - skip unnecessary mob spawning computations ++ + private void getFullChunk(long pos, Consumer chunkConsumer) { + ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos); + diff --git a/patches/server/0116-Prevent-entities-random-strolling-into-non-ticking-c.patch b/patches/server/0117-Prevent-entities-random-strolling-into-non-ticking-c.patch similarity index 100% rename from patches/server/0116-Prevent-entities-random-strolling-into-non-ticking-c.patch rename to patches/server/0117-Prevent-entities-random-strolling-into-non-ticking-c.patch diff --git a/patches/server/0117-CraftBukkit-UUID-to-world-map.patch b/patches/server/0118-CraftBukkit-UUID-to-world-map.patch similarity index 100% rename from patches/server/0117-CraftBukkit-UUID-to-world-map.patch rename to patches/server/0118-CraftBukkit-UUID-to-world-map.patch diff --git a/patches/server/0118-Don-t-double-save-stored-user-lists.patch b/patches/server/0119-Don-t-double-save-stored-user-lists.patch similarity index 100% rename from patches/server/0118-Don-t-double-save-stored-user-lists.patch rename to patches/server/0119-Don-t-double-save-stored-user-lists.patch diff --git a/patches/server/0119-Specific-interval-TPS-API.patch b/patches/server/0120-Specific-interval-TPS-API.patch similarity index 100% rename from patches/server/0119-Specific-interval-TPS-API.patch rename to patches/server/0120-Specific-interval-TPS-API.patch diff --git a/patches/server/0120-5-second-TPS-average.patch b/patches/server/0121-5-second-TPS-average.patch similarity index 100% rename from patches/server/0120-5-second-TPS-average.patch rename to patches/server/0121-5-second-TPS-average.patch diff --git a/patches/server/0121-Measure-last-tick-time.patch b/patches/server/0122-Measure-last-tick-time.patch similarity index 100% rename from patches/server/0121-Measure-last-tick-time.patch rename to patches/server/0122-Measure-last-tick-time.patch diff --git a/patches/server/0122-Last-tick-time-API.patch b/patches/server/0123-Last-tick-time-API.patch similarity index 100% rename from patches/server/0122-Last-tick-time-API.patch rename to patches/server/0123-Last-tick-time-API.patch diff --git a/patches/server/0123-Show-last-tick-time-in-tps-command.patch b/patches/server/0124-Show-last-tick-time-in-tps-command.patch similarity index 100% rename from patches/server/0123-Show-last-tick-time-in-tps-command.patch rename to patches/server/0124-Show-last-tick-time-in-tps-command.patch diff --git a/patches/server/0124-Increase-time-statistics-in-intervals.patch b/patches/server/0125-Increase-time-statistics-in-intervals.patch similarity index 100% rename from patches/server/0124-Increase-time-statistics-in-intervals.patch rename to patches/server/0125-Increase-time-statistics-in-intervals.patch diff --git a/patches/server/0125-For-collision-check-has-physics-before-same-vehicle.patch b/patches/server/0126-For-collision-check-has-physics-before-same-vehicle.patch similarity index 100% rename from patches/server/0125-For-collision-check-has-physics-before-same-vehicle.patch rename to patches/server/0126-For-collision-check-has-physics-before-same-vehicle.patch diff --git a/patches/server/0126-Skip-negligible-planar-movement-multiplication.patch b/patches/server/0127-Skip-negligible-planar-movement-multiplication.patch similarity index 100% rename from patches/server/0126-Skip-negligible-planar-movement-multiplication.patch rename to patches/server/0127-Skip-negligible-planar-movement-multiplication.patch diff --git a/patches/server/0127-Reduce-RandomSource-instances.patch b/patches/server/0128-Reduce-RandomSource-instances.patch similarity index 100% rename from patches/server/0127-Reduce-RandomSource-instances.patch rename to patches/server/0128-Reduce-RandomSource-instances.patch diff --git a/patches/server/0128-Server-thread-priority-environment-variable.patch b/patches/server/0129-Server-thread-priority-environment-variable.patch similarity index 100% rename from patches/server/0128-Server-thread-priority-environment-variable.patch rename to patches/server/0129-Server-thread-priority-environment-variable.patch diff --git a/patches/server/0129-Thread-safety-annotations.patch b/patches/server/0130-Thread-safety-annotations.patch similarity index 100% rename from patches/server/0129-Thread-safety-annotations.patch rename to patches/server/0130-Thread-safety-annotations.patch diff --git a/patches/server/0130-CPU-cores-estimation.patch b/patches/server/0131-CPU-cores-estimation.patch similarity index 100% rename from patches/server/0130-CPU-cores-estimation.patch rename to patches/server/0131-CPU-cores-estimation.patch diff --git a/patches/server/0131-Mutex-utility.patch b/patches/server/0132-Mutex-utility.patch similarity index 100% rename from patches/server/0131-Mutex-utility.patch rename to patches/server/0132-Mutex-utility.patch diff --git a/patches/server/0132-Paired-lock-and-condition-utility.patch b/patches/server/0133-Paired-lock-and-condition-utility.patch similarity index 100% rename from patches/server/0132-Paired-lock-and-condition-utility.patch rename to patches/server/0133-Paired-lock-and-condition-utility.patch diff --git a/patches/server/0133-Unterminable-executor-utility.patch b/patches/server/0134-Unterminable-executor-utility.patch similarity index 100% rename from patches/server/0133-Unterminable-executor-utility.patch rename to patches/server/0134-Unterminable-executor-utility.patch diff --git a/patches/server/0134-FIFO-concurrent-queue-utility.patch b/patches/server/0135-FIFO-concurrent-queue-utility.patch similarity index 100% rename from patches/server/0134-FIFO-concurrent-queue-utility.patch rename to patches/server/0135-FIFO-concurrent-queue-utility.patch diff --git a/patches/server/0135-Base-thread-pools.patch b/patches/server/0136-Base-thread-pools.patch similarity index 99% rename from patches/server/0135-Base-thread-pools.patch rename to patches/server/0136-Base-thread-pools.patch index 292f9a8..87c4e39 100644 --- a/patches/server/0135-Base-thread-pools.patch +++ b/patches/server/0136-Base-thread-pools.patch @@ -1299,7 +1299,7 @@ index eed9f125df46b616b7234a2d669971bc51bc231b..396258cb21a8e5488f0f456b65dc629f // CraftBukkit end this.settings = dedicatedserversettings; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 8ed18a158a13dceca7cd342125c09e52ac0d013c..d513245ec5fadfa511895feeef73d2a57bd21160 100644 +index df4db98618c6c9261b4ec8e2987c4ed26af4bd4b..5f0eb08636ffa742de7e804a03c9cf2cea0afd1a 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -11,7 +11,6 @@ import java.util.Collections; @@ -1326,7 +1326,7 @@ index 8ed18a158a13dceca7cd342125c09e52ac0d013c..d513245ec5fadfa511895feeef73d2a5 public class ServerChunkCache extends ChunkSource { -@@ -977,6 +978,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -999,6 +1000,14 @@ public class ServerChunkCache extends ChunkSource { super.doRunTask(task); } diff --git a/patches/server/0136-Non-blocking-PooledObjects.patch b/patches/server/0137-Non-blocking-PooledObjects.patch similarity index 100% rename from patches/server/0136-Non-blocking-PooledObjects.patch rename to patches/server/0137-Non-blocking-PooledObjects.patch