2021-05-15 09:07:30 +10:00
|
|
|
From cf4cb376a53f6a796b6458c00f83af3e384c4139 Mon Sep 17 00:00:00 2001
|
2018-07-15 10:00:00 +10:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Fri, 21 Jun 2013 17:29:54 +1000
|
|
|
|
Subject: [PATCH] Fix Mob Spawning Relative to View Distance
|
|
|
|
|
|
|
|
Changes the mob spawning algorithm to properly account for view distance and the range around players.
|
|
|
|
|
|
|
|
Needs better documentation.
|
|
|
|
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
|
|
index d5de3e3e8..e95f51675 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
|
|
@@ -423,7 +423,7 @@ public class ChunkProviderServer extends IChunkProvider {
|
2020-06-25 10:00:00 +10:00
|
|
|
|
|
|
|
if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
|
|
|
|
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
|
|
|
|
- if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos())) {
|
|
|
|
+ if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
|
|
|
|
SpawnerCreature.a(this.world, chunk, spawnercreature_d, this.allowAnimals, this.allowMonsters, flag2);
|
|
|
|
}
|
2019-05-29 19:39:32 +10:00
|
|
|
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2021-05-15 09:07:30 +10:00
|
|
|
index 6fd7cc2e8..7ca5068fb 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2021-05-15 09:07:30 +10:00
|
|
|
@@ -906,10 +906,21 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
2019-04-23 12:00:00 +10:00
|
|
|
}
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2019-07-20 09:00:00 +10:00
|
|
|
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
|
|
|
+ // Spigot start
|
|
|
|
+ return isOutsideOfRange(chunkcoordintpair, false);
|
|
|
|
+ }
|
|
|
|
+
|
2019-06-02 19:56:20 +10:00
|
|
|
+ boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair, boolean reducedRange) {
|
2019-04-23 12:00:00 +10:00
|
|
|
+ int chunkRange = world.spigotConfig.mobSpawnRange;
|
|
|
|
+ chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
|
|
|
|
+ chunkRange = (chunkRange > 8) ? 8 : chunkRange;
|
|
|
|
+
|
2019-05-29 19:39:32 +10:00
|
|
|
+ double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D;
|
2019-04-23 12:00:00 +10:00
|
|
|
+ // Spigot end
|
2019-06-21 20:00:00 +10:00
|
|
|
long i = chunkcoordintpair.pair();
|
|
|
|
|
2019-07-20 09:00:00 +10:00
|
|
|
return !this.chunkDistanceManager.d(i) ? true : this.playerMap.a(i).noneMatch((entityplayer) -> {
|
2019-04-23 12:00:00 +10:00
|
|
|
- return !entityplayer.isSpectator() && a(chunkcoordintpair, (Entity) entityplayer) < 16384.0D;
|
|
|
|
+ return !entityplayer.isSpectator() && a(chunkcoordintpair, (Entity) entityplayer) < blockRange; // Spigot
|
|
|
|
});
|
|
|
|
}
|
2018-07-15 10:00:00 +10:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2021-01-31 10:08:46 +11:00
|
|
|
index 8db1bc203..e780cc473 100644
|
2018-07-15 10:00:00 +10:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2019-08-08 20:48:47 +10:00
|
|
|
@@ -161,4 +161,11 @@ public class SpigotWorldConfig
|
2021-01-31 10:08:46 +11:00
|
|
|
viewDistance = Math.max( Math.min( viewDistance, 32 ), 3 );
|
2018-07-15 10:00:00 +10:00
|
|
|
log( "View Distance: " + viewDistance );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public byte mobSpawnRange;
|
|
|
|
+ private void mobSpawnRange()
|
|
|
|
+ {
|
2018-08-06 10:32:15 +10:00
|
|
|
+ mobSpawnRange = (byte) getInt( "mob-spawn-range", 6 );
|
2018-07-15 10:00:00 +10:00
|
|
|
+ log( "Mob Spawn Range: " + mobSpawnRange );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2020-05-09 18:48:11 +10:00
|
|
|
2.25.1
|
2018-07-15 10:00:00 +10:00
|
|
|
|