2019-04-26 16:59:36 +10:00
|
|
|
From 6f07074d2445ea7cc857a7cdc97c25d49fe20961 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.
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2019-04-26 16:59:36 +10:00
|
|
|
index 086e19fab..90941b2ad 100644
|
2019-04-23 12:00:00 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2019-04-26 16:59:36 +10:00
|
|
|
@@ -657,8 +657,16 @@ 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-04-23 12:00:00 +10:00
|
|
|
boolean d(ChunkCoordIntPair chunkcoordintpair) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ int chunkRange = world.spigotConfig.mobSpawnRange;
|
|
|
|
+ chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
|
|
|
|
+ chunkRange = (chunkRange > 8) ? 8 : chunkRange;
|
|
|
|
+
|
|
|
|
+ double blockRange = Math.pow(chunkRange << 4, 2);
|
|
|
|
+ // Spigot end
|
2018-07-15 10:00:00 +10:00
|
|
|
+
|
2019-04-23 12:00:00 +10:00
|
|
|
return this.y.a(chunkcoordintpair.pair()).noneMatch((entityplayer) -> {
|
|
|
|
- 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
|
2019-04-25 12:00:00 +10:00
|
|
|
index 0dd4b2d37..bcf5d1653 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
|
2018-12-27 10:53:44 +11:00
|
|
|
@@ -132,4 +132,11 @@ public class SpigotWorldConfig
|
2018-07-15 10:00:00 +10:00
|
|
|
viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
|
|
|
|
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 );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2019-04-23 09:33:25 +10:00
|
|
|
2.20.1
|
2018-07-15 10:00:00 +10:00
|
|
|
|