Use simulation distance for per-player mob spawns (#7247)

This commit is contained in:
sean 2022-01-02 15:05:08 +01:00
parent ffa0464d81
commit fc1c86477e
3 changed files with 20 additions and 3 deletions

View File

@ -247,7 +247,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
}
@@ -0,0 +0,0 @@ public abstract class DistanceManager {
}
// Paper end
public int getNaturalSpawnChunkCount() {
- this.naturalSpawnChunkCounter.runAllUpdates();

View File

@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't update when animals and monsters are disabled
// update distance map
this.level.timings.playerMobDistanceMapUpdate.startTiming();
this.chunkMap.playerMobDistanceMap.update(this.level.players, this.chunkMap.viewDistance);
this.chunkMap.playerMobDistanceMap.update(this.level.players, this.distanceManager.getSimulationDistance());

View File

@ -592,6 +592,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8);
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -0,0 +0,0 @@ public abstract class DistanceManager {
}
+ // Paper start
+ public int getSimulationDistance() {
+ return this.simulationDistance;
+ }
+ // Paper end
+
public int getNaturalSpawnChunkCount() {
this.naturalSpawnChunkCounter.runAllUpdates();
return this.naturalSpawnChunkCounter.chunks.size();
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@ -606,7 +623,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (this.chunkMap.playerMobDistanceMap != null) {
+ // update distance map
+ this.level.timings.playerMobDistanceMapUpdate.startTiming();
+ this.chunkMap.playerMobDistanceMap.update(this.level.players, this.chunkMap.viewDistance);
+ this.chunkMap.playerMobDistanceMap.update(this.level.players, this.distanceManager.getSimulationDistance());
+ this.level.timings.playerMobDistanceMapUpdate.stopTiming();
+ // re-set mob counts
+ for (ServerPlayer player : this.level.players) {