Skip to content

Commit

Permalink
Fix animal spawning issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Siroshun09 authored and Spottedleaf committed Nov 21, 2023
1 parent 7aacf90 commit d58fab2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion patches/server/0003-Threaded-Regions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0018-Region-profiler.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d58fab2

Please sign in to comment.