2019-05-29 19:39:32 +10:00
|
|
|
From c72e7946f79ee96f8890b76578acfc757d790826 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-05-29 19:39:32 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
index e278dc636..ea142d76a 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
@@ -319,9 +319,9 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
|
|
this.world.getMethodProfiler().exit();
|
|
|
|
ChunkCoordIntPair chunkcoordintpair = playerchunk.h();
|
|
|
|
|
|
|
|
- if (!this.playerChunkMap.d(chunkcoordintpair)) {
|
|
|
|
+ if (!this.playerChunkMap.d(chunkcoordintpair, false)) { // Spigot
|
|
|
|
chunk.b(chunk.q() + 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.d(chunkcoordintpair, true)) { // Spigot
|
|
|
|
this.world.getMethodProfiler().enter("spawner");
|
|
|
|
this.world.timings.mobSpawn.startTiming(); // Spigot
|
|
|
|
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
|
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-29 19:39:32 +10:00
|
|
|
index cfb6b679b..9e189ccdf 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-29 19:39:32 +10:00
|
|
|
@@ -739,9 +739,17 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
|
|
return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
2019-04-23 12:00:00 +10:00
|
|
|
}
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2019-05-29 19:39:32 +10:00
|
|
|
- boolean d(ChunkCoordIntPair chunkcoordintpair) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ boolean d(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
|
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
|
|
|
|