mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-05 22:52:13 -07:00
Use simulation distance for per-player mob spawns (#7247)
This commit is contained in:
@@ -247,7 +247,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
|
this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public abstract class DistanceManager {
|
@@ -0,0 +0,0 @@ public abstract class DistanceManager {
|
||||||
}
|
// Paper end
|
||||||
|
|
||||||
public int getNaturalSpawnChunkCount() {
|
public int getNaturalSpawnChunkCount() {
|
||||||
- this.naturalSpawnChunkCounter.runAllUpdates();
|
- this.naturalSpawnChunkCounter.runAllUpdates();
|
||||||
|
@@ -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
|
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't update when animals and monsters are disabled
|
||||||
// update distance map
|
// update distance map
|
||||||
this.level.timings.playerMobDistanceMapUpdate.startTiming();
|
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());
|
||||||
|
@@ -592,6 +592,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
|
private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
|
||||||
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
|
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
|
||||||
double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
@@ -606,7 +623,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ if (this.chunkMap.playerMobDistanceMap != null) {
|
+ if (this.chunkMap.playerMobDistanceMap != null) {
|
||||||
+ // update distance map
|
+ // update distance map
|
||||||
+ this.level.timings.playerMobDistanceMapUpdate.startTiming();
|
+ 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();
|
+ this.level.timings.playerMobDistanceMapUpdate.stopTiming();
|
||||||
+ // re-set mob counts
|
+ // re-set mob counts
|
||||||
+ for (ServerPlayer player : this.level.players) {
|
+ for (ServerPlayer player : this.level.players) {
|
||||||
|
Reference in New Issue
Block a user