2019-05-28 06:30:00 +10:00
|
|
|
From 4cb47d83fc9d7ab055fdc4d4476fa2087c5629d8 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-05-28 06:30:00 +10:00
|
|
|
index cfb6b679b..bf6801bae 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-05-28 06:30:00 +10:00
|
|
|
@@ -740,8 +740,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-05-14 10:00:00 +10:00
|
|
|
return this.playerMap.a(chunkcoordintpair.pair()).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
|
2019-04-30 12:16:33 +10:00
|
|
|
index 47e959af0..fc592d814 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-04-30 12:16:33 +10:00
|
|
|
@@ -148,4 +148,11 @@ public class SpigotWorldConfig
|
|
|
|
viewDistance = Math.max( viewDistance, 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 );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2019-04-23 09:33:25 +10:00
|
|
|
2.20.1
|
2018-07-15 10:00:00 +10:00
|
|
|
|