Skip to content

Commit d3f3429

Browse files
authored
Use simulation distance for per-player mob spawns (#7247)
1 parent 503ac8f commit d3f3429

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

patches/server/0364-implement-optional-per-player-mob-spawns.patch

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,25 @@ index 0c82b270c7095c7e4666a8078ecc7142503795c4..0583d7ee24f694fbf5138dfae9f7b8c8
592592
private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
593593
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
594594
double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8);
595+
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
596+
index f0dac1f596911eb2109192ef16a619f8ae71d1f7..07b616d9d7cde77c001f5c627daef0731d883e61 100644
597+
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
598+
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
599+
@@ -323,6 +323,12 @@ public abstract class DistanceManager {
600+
601+
}
602+
603+
+ // Paper start
604+
+ public int getSimulationDistance() {
605+
+ return this.simulationDistance;
606+
+ }
607+
+ // Paper end
608+
+
609+
public int getNaturalSpawnChunkCount() {
610+
this.naturalSpawnChunkCounter.runAllUpdates();
611+
return this.naturalSpawnChunkCounter.chunks.size();
595612
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
596-
index 7b391d6ab84eeaed7bdd27ea70d5e3f9690a0abf..17a36ee61aacfc41e2d926335c460350cd25ab42 100644
613+
index 7b391d6ab84eeaed7bdd27ea70d5e3f9690a0abf..d9405456f61b954f9b6fa2fa7939fc3a36ec6fc6 100644
597614
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
598615
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
599616
@@ -916,7 +916,22 @@ public class ServerChunkCache extends ChunkSource {
@@ -606,7 +623,7 @@ index 7b391d6ab84eeaed7bdd27ea70d5e3f9690a0abf..17a36ee61aacfc41e2d926335c460350
606623
+ if (this.chunkMap.playerMobDistanceMap != null) {
607624
+ // update distance map
608625
+ this.level.timings.playerMobDistanceMapUpdate.startTiming();
609-
+ this.chunkMap.playerMobDistanceMap.update(this.level.players, this.chunkMap.viewDistance);
626+
+ this.chunkMap.playerMobDistanceMap.update(this.level.players, this.distanceManager.getSimulationDistance());
610627
+ this.level.timings.playerMobDistanceMapUpdate.stopTiming();
611628
+ // re-set mob counts
612629
+ for (ServerPlayer player : this.level.players) {

patches/server/0432-Optimize-anyPlayerCloseEnoughForSpawning-to-use-dist.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..87b612c25f865af4c8da72c761b70094
207207

208208
public List<ServerPlayer> getPlayersCloseForSpawning(ChunkPos pos) {
209209
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
210-
index 8868ffcda194e8c2300181a2cdda9337dbde6284..95f195980e28bb59f43e5ca1d5e79ebe8c3ddaea 100644
210+
index f11e9421d393ef5a04f24c78a1214359710cc2f8..3865146697051e01a778414064425ea0e5162b8d 100644
211211
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
212212
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
213213
@@ -48,7 +48,7 @@ public abstract class DistanceManager {
@@ -246,8 +246,8 @@ index 8868ffcda194e8c2300181a2cdda9337dbde6284..95f195980e28bb59f43e5ca1d5e79ebe
246246
this.playerTicketManager.update(i, Integer.MAX_VALUE, false);
247247
this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
248248
}
249-
@@ -324,13 +324,17 @@ public abstract class DistanceManager {
250-
}
249+
@@ -330,13 +330,17 @@ public abstract class DistanceManager {
250+
// Paper end
251251

252252
public int getNaturalSpawnChunkCount() {
253253
- this.naturalSpawnChunkCounter.runAllUpdates();
@@ -269,7 +269,7 @@ index 8868ffcda194e8c2300181a2cdda9337dbde6284..95f195980e28bb59f43e5ca1d5e79ebe
269269

270270
public String getDebugStatus() {
271271
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
272-
index 66dfe3d79fa3273a2bab64193f73f2b38002c18c..1115df1f148bcb079edb9eb397de3fab725bf83b 100644
272+
index 50f3be85039c698bb2f73116a397d6ddaeea6dbd..b10ed9f87e58983863864161457cd415bb782bfd 100644
273273
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
274274
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
275275
@@ -881,6 +881,37 @@ public class ServerChunkCache extends ChunkSource {

patches/server/0590-Skip-distance-map-update-when-spawning-disabled.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Skip distance map update when spawning disabled.
55

66

77
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
8-
index 42cecd0f072505c80b65ccf26e5d838750d21e28..dcb65eb4e5790e12ebe83b0d25b5a8c7a8bfbb6b 100644
8+
index 1ff2d926ca5de9334b1e5aa5defb73d7fbc1c3af..8e87cc36b57bc5e8f8eb5583e02bbede4eb9ce54 100644
99
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
1010
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
1111
@@ -966,7 +966,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -16,4 +16,4 @@ index 42cecd0f072505c80b65ccf26e5d838750d21e28..dcb65eb4e5790e12ebe83b0d25b5a8c7
1616
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't update when animals and monsters are disabled
1717
// update distance map
1818
this.level.timings.playerMobDistanceMapUpdate.startTiming();
19-
this.chunkMap.playerMobDistanceMap.update(this.level.players, this.chunkMap.viewDistance);
19+
this.chunkMap.playerMobDistanceMap.update(this.level.players, this.distanceManager.getSimulationDistance());

0 commit comments

Comments
 (0)