From d58fab2cceeabe47b2f0925bb0bde551c46029e9 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Wed, 22 Nov 2023 06:06:34 +0900 Subject: [PATCH] Fix animal spawning issue --- patches/server/0003-Threaded-Regions.patch | 11 ++++++++++- patches/server/0018-Region-profiler.patch | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/patches/server/0003-Threaded-Regions.patch b/patches/server/0003-Threaded-Regions.patch index f3ad3ca..aaacd1f 100644 --- a/patches/server/0003-Threaded-Regions.patch +++ b/patches/server/0003-Threaded-Regions.patch @@ -12717,7 +12717,7 @@ index 55f96545d6db95e3e657502a7910d96fded1113e..b39dd5a11a34407244666d8b9c1e775d 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 8c33a12ca879c46893150d6adfb8aa4d397c6b4c..a97c0a86d7a07041d1f8e9c6ea59eb4cce1243e6 100644 +index 8c33a12ca879c46893150d6adfb8aa4d397c6b4c..4ed40924942bc3252fb1a533190765fbfdb2ba72 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -60,73 +60,42 @@ public class ServerChunkCache extends ChunkSource { @@ -12875,6 +12875,15 @@ index 8c33a12ca879c46893150d6adfb8aa4d397c6b4c..a97c0a86d7a07041d1f8e9c6ea59eb4c gameprofilerfiller.push("naturalSpawnCount"); this.level.timings.countNaturalMobs.startTiming(); // Paper - timings +@@ -531,7 +482,7 @@ public class ServerChunkCache extends ChunkSource { + NaturalSpawner.SpawnState spawnercreature_d; // moved down + if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled + // re-set mob counts +- for (ServerPlayer player : this.level.players) { ++ for (ServerPlayer player : regionizedWorldData.getLocalPlayers()) { // Folia - region threading + // Paper start - per player mob spawning backoff + for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) { + player.mobCounts[ii] = 0; @@ -544,14 +495,14 @@ public class ServerChunkCache extends ChunkSource { } // Paper end - per player mob spawning backoff diff --git a/patches/server/0018-Region-profiler.patch b/patches/server/0018-Region-profiler.patch index 081e701..8d3ca1d 100644 --- a/patches/server/0018-Region-profiler.patch +++ b/patches/server/0018-Region-profiler.patch @@ -1518,7 +1518,7 @@ index f640a0b8742a8362401f91a9a0f8fbb31885dca0..50597a8b45bbd7dcc40b361da78358d9 // Folia end - region threading - replace entity tracking ticking diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index a97c0a86d7a07041d1f8e9c6ea59eb4cce1243e6..4484063433a3dbf87e244a7857d85cc732f6ccd2 100644 +index 4ed40924942bc3252fb1a533190765fbfdb2ba72..b9b1dfe04eda8498f0ceff0aee66489d2a02b814 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -436,16 +436,23 @@ public class ServerChunkCache extends ChunkSource { @@ -1560,7 +1560,7 @@ index a97c0a86d7a07041d1f8e9c6ea59eb4cce1243e6..4484063433a3dbf87e244a7857d85cc7 + profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); try { // Folia - profiler if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts - for (ServerPlayer player : this.level.players) { + for (ServerPlayer player : regionizedWorldData.getLocalPlayers()) { // Folia - region threading @@ -499,6 +508,7 @@ public class ServerChunkCache extends ChunkSource { } else { spawnercreature_d = NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); // Folia - region threading