mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 18:15:54 +01:00
Mob spawning issues - 'fix'. See below for ideal reasoning from MikePrimm, however until ideal reasoning we must live with the CraftBukkit / Vanilla behaviour since this causes far too many issues.
IIRC, the main item I was driving towards was a consequence of persistent passive mobs - specifically, the fact that allowing a population limit of N (independent of view distance, which is what vanilla does) when your view distance limits actual loaded chunks to a much smaller area than default (say a view of 4, which would be 9 x 9 chunks loaded per player - and spawnable - versus default, which is 8 radius spawn, or 17 x 17 chunks) tends to result in more mobs per chunk. For persistent mobs, this is bad - since they count for server load and for population just by being loaded, versus being despawned beyond 128 blocks (8 chunk radius - unconditional of view distance, as well) - so they can cause the population limit to be reached more easily, cutting off spawning nearer to players. The goal was to make it so that the mobs-per-loaded-chunk was about the same for all view distances, versus having low view distances cause higher mob concentrations. Now, all of this assumes that loaded chunks beyond those around players are modest (since they could contain passive mobs that would count towards the limits) - which they should be, except that recent CBs leak chunks like mad, from what I can see (chunk-gc has become more required than optional), and I think there may be some issues with even hostile mobs "lurking" around - possibly even after their chunks are unloaded. Anything that causes more mobs to be in places players don't see them is going to drive population limit issues, and resulting low spawn behaviors. The trick for us, trying to make big servers as practical as possible, is to shift the math the other way - given low view distances, how to best make sure that folks get reasonable spawn behavior while minimizing the time/resources spent on the server on mobs that don't help that. Realistically, I think we need to analyse the mob demographics better - especially as it relates to lower view distances (our changes have no net impact on view distances above 7) - particularly to understand how the proportion of "useful" mobs is working out (ones close enough to players to be considered contributing to game play). One thought is to manage the population limit based on mobs that are 'tickable' - if they aren't close enough to be ticking, they aren't interesting. This is likely a big issue for view distance 5 folks, since mobs cannot spawn closer than 24 (approx 1 chunk radius, given that middle chunk is 0), and don't tick when any of the chunks within a 2 chunk radius aren't loaded) - so, effectively, they "live" within a zone of 7 x 7 with the middle 3 x 3 removed (so, about 40 chunks) out of a total load zone of 11 x 11 (121) - so about 2/3 of the area containing mobs has idle mobs. Normal view distance would result in mobs ticking as far out as they can spawn (radius 8 versus a load radius of 11), so 100% of the mobs that spawn are ticking when they spawn, and all hostile mobs that are loaded are ticking (since they always despawn beyond 128 blocks / 8 chunks from a player). One interesting thought would be to limit the chunks we spawn mobs in to those where they would be ticking initially (that is, view-distance minus 2 or 3).
This commit is contained in:
parent
165c72a896
commit
a65fedb3f8
@ -1,6 +1,6 @@
|
||||
From 1f766e4a465e4eed65061fd7a908ea22e8c0d6fa Mon Sep 17 00:00:00 2001
|
||||
From 47c9f07d091d4669fd669569ee924ba083c19b21 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 22 Jan 2013 15:56:54 +1100
|
||||
Date: Tue, 29 Jan 2013 16:51:35 +1100
|
||||
Subject: [PATCH] Spigot changes.
|
||||
|
||||
---
|
||||
@ -24,7 +24,6 @@ Subject: [PATCH] Spigot changes.
|
||||
.../java/net/minecraft/server/MinecraftServer.java | 51 +--
|
||||
.../net/minecraft/server/PlayerConnection.java | 18 +-
|
||||
src/main/java/net/minecraft/server/PlayerList.java | 10 +-
|
||||
.../java/net/minecraft/server/SpawnerCreature.java | 23 +-
|
||||
.../net/minecraft/server/ThreadLoginVerifier.java | 23 +
|
||||
src/main/java/net/minecraft/server/World.java | 200 ++++++++-
|
||||
.../java/net/minecraft/server/WorldServer.java | 122 +++++-
|
||||
@ -44,7 +43,7 @@ Subject: [PATCH] Spigot changes.
|
||||
.../org/bukkit/craftbukkit/util/TimedThread.java | 37 ++
|
||||
.../bukkit/craftbukkit/util/WatchdogThread.java | 88 ++++
|
||||
src/main/resources/configurations/bukkit.yml | 30 ++
|
||||
40 files changed, 1444 insertions(+), 137 deletions(-)
|
||||
39 files changed, 1424 insertions(+), 134 deletions(-)
|
||||
create mode 100644 src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
create mode 100644 src/main/java/org/bukkit/craftbukkit/command/RestartCommand.java
|
||||
create mode 100644 src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java
|
||||
@ -613,72 +612,6 @@ index f669a00..dee6579 100644
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
index 9b3e262..61721c4 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
@@ -16,6 +16,7 @@ public final class SpawnerCreature {
|
||||
|
||||
private static LongObjectHashMap<Boolean> b = new LongObjectHashMap<Boolean>(); // CraftBukkit - HashMap -> LongObjectHashMap
|
||||
protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class};
|
||||
+ private static byte spawnRadius = 0; // Spigot
|
||||
|
||||
protected static ChunkPosition getRandomPosition(World world, int i, int j) {
|
||||
Chunk chunk = world.getChunkAt(i, j);
|
||||
@@ -34,13 +35,21 @@ public final class SpawnerCreature {
|
||||
|
||||
int i;
|
||||
int j;
|
||||
+ // Spigot start - limit radius to spawn distance (chunks aren't loaded)
|
||||
+ if (spawnRadius == 0) {
|
||||
+ spawnRadius = (byte) worldserver.getServer().getViewDistance();
|
||||
+ if (spawnRadius > 8) {
|
||||
+ spawnRadius = 8;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
for (i = 0; i < worldserver.players.size(); ++i) {
|
||||
EntityHuman entityhuman = (EntityHuman) worldserver.players.get(i);
|
||||
int k = MathHelper.floor(entityhuman.locX / 16.0D);
|
||||
|
||||
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
||||
- byte b0 = 8;
|
||||
+ byte b0 = spawnRadius; // Spigot - replace 8 with view distance constrained value
|
||||
|
||||
for (int l = -b0; l <= b0; ++l) {
|
||||
for (int i1 = -b0; i1 <= b0; ++i1) {
|
||||
@@ -88,13 +97,15 @@ public final class SpawnerCreature {
|
||||
if (limit == 0) {
|
||||
continue;
|
||||
}
|
||||
+ int mobcnt = 0;
|
||||
// CraftBukkit end
|
||||
|
||||
- if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
|
||||
+ if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && (mobcnt = worldserver.a(enumcreaturetype.a())) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
|
||||
Iterator iterator = b.keySet().iterator();
|
||||
|
||||
+ int moblimit = (limit * b.size() / 256) - mobcnt + 1; // CraftBukkit - up to 1 more than limit
|
||||
label110:
|
||||
- while (iterator.hasNext()) {
|
||||
+ while (iterator.hasNext() && (moblimit > 0)) { // Spigot - while more allowed
|
||||
// CraftBukkit start
|
||||
long key = ((Long) iterator.next()).longValue();
|
||||
|
||||
@@ -158,6 +169,12 @@ public final class SpawnerCreature {
|
||||
a(entityliving, worldserver, f, f1, f2);
|
||||
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ moblimit--;
|
||||
+ if (moblimit <= 0) { // If we're past limit, stop spawn
|
||||
+ continue label110;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
if (j2 >= entityliving.bv()) {
|
||||
continue label110;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
||||
index 0686ba0..58d30eb 100644
|
||||
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 929f3cb5c059f90180b7a3a71fb2079c99baa133 Mon Sep 17 00:00:00 2001
|
||||
From c88bb483e5104872c4492f006b107625f9c91939 Mon Sep 17 00:00:00 2001
|
||||
From: Agaricus <agaricusb@yahoo.com>
|
||||
Date: Sun, 13 Jan 2013 03:41:38 -0800
|
||||
Subject: [PATCH] Add OldChunkLoader from mc-dev for diff visibility
|
@ -1,28 +0,0 @@
|
||||
From c7e9f844a4bee1592da4705c09028546a546d426 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 11 Jan 2013 14:54:51 -0500
|
||||
Subject: [PATCH] Fix mob-spawn-radius setting so that its actually used...
|
||||
|
||||
---
|
||||
src/main/java/net/minecraft/server/SpawnerCreature.java | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
index 61721c4..124b143 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
@@ -37,7 +37,10 @@ public final class SpawnerCreature {
|
||||
int j;
|
||||
// Spigot start - limit radius to spawn distance (chunks aren't loaded)
|
||||
if (spawnRadius == 0) {
|
||||
- spawnRadius = (byte) worldserver.getServer().getViewDistance();
|
||||
+ spawnRadius = (byte) worldserver.getWorld().mobSpawnRange;
|
||||
+ if (spawnRadius > (byte) worldserver.getServer().getViewDistance()) {
|
||||
+ spawnRadius = (byte) worldserver.getServer().getViewDistance();
|
||||
+ }
|
||||
if (spawnRadius > 8) {
|
||||
spawnRadius = 8;
|
||||
}
|
||||
--
|
||||
1.8.1-rc2
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 2de29f11f996690e92c275f9fcd0eabcb84972bf Mon Sep 17 00:00:00 2001
|
||||
From 6d940cd4bc4a1b7ba8e918f25711e916274adb4d Mon Sep 17 00:00:00 2001
|
||||
From: Agaricus <agaricusb@yahoo.com>
|
||||
Date: Sun, 13 Jan 2013 03:49:07 -0800
|
||||
Subject: [PATCH] Fix mcRegion-to-Anvil conversion
|
@ -1,4 +1,4 @@
|
||||
From 820fbd7ead50871bf254add75d4e8cd68d9a40a5 Mon Sep 17 00:00:00 2001
|
||||
From 85c87e793adf22f192b06945bdb404e2bc51c5b0 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@bigpond.com>
|
||||
Date: Tue, 15 Jan 2013 11:48:54 +1100
|
||||
Subject: [PATCH] Update pom with Spigot specific info.
|
@ -1,4 +1,4 @@
|
||||
From f3facbff6ce361fb4ab59d3814ce384f8b2a636b Mon Sep 17 00:00:00 2001
|
||||
From eb2fad1de55d855c05ec5c64610ddaa1f050951d Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@bigpond.com>
|
||||
Date: Tue, 15 Jan 2013 15:05:02 +1100
|
||||
Subject: [PATCH] Update versioning check to correctly resolve api version.
|
@ -1,4 +1,4 @@
|
||||
From 665d2d79c486bf4d8ee4efe98ef0810f96b43c8c Mon Sep 17 00:00:00 2001
|
||||
From 2c5bbb8b0dca630b5035d88335f810d39d065eb6 Mon Sep 17 00:00:00 2001
|
||||
From: Ammar Askar <ammar@ammaraskar.com>
|
||||
Date: Fri, 18 Jan 2013 16:20:01 +0500
|
||||
Subject: [PATCH] Optimize packet used to unload chunks for the client
|
@ -1,4 +1,4 @@
|
||||
From f783c54e66aff8a835da46d1849af4d2157e8818 Mon Sep 17 00:00:00 2001
|
||||
From 824fbe25325c37bae8a2667d7344b922bc73d086 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 19 Jan 2013 01:11:30 -0500
|
||||
Subject: [PATCH] Skip entity.move() if we are not moving anywhere.
|
||||
@ -8,7 +8,7 @@ Subject: [PATCH] Skip entity.move() if we are not moving anywhere.
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index e1d611e..83f7ae8 100644
|
||||
index dffa97f..066143c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -423,6 +423,7 @@ public abstract class Entity {
|
@ -1,4 +1,4 @@
|
||||
From 3b1fe146746b93011b0a7bab56281160f6461cd1 Mon Sep 17 00:00:00 2001
|
||||
From 3db9355f95b3286195da752818eed63e3312ec0c Mon Sep 17 00:00:00 2001
|
||||
From: Mike Primm <mike@primmhome.com>
|
||||
Date: Wed, 16 Jan 2013 15:27:22 -0600
|
||||
Subject: [PATCH] Alternate, sync-free-but-safe chunk reference cache
|
@ -1,4 +1,4 @@
|
||||
From 8de0c8dfd462f4023fb85beb91afe4cf33d7ab30 Mon Sep 17 00:00:00 2001
|
||||
From 944da35dce1c28a62ac3b019ae791d2ce20b6648 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 10 Jan 2013 00:18:11 -0500
|
||||
Subject: [PATCH] Add Custom Timings to various points
|
@ -1,4 +1,4 @@
|
||||
From 36b9793a096db8f3a5f726b8792ddd1315a88081 Mon Sep 17 00:00:00 2001
|
||||
From 1bb40d4b3fc5159e7c8e07b826d2f2009bbcf4d8 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Fri, 25 Jan 2013 18:24:54 +1100
|
||||
Subject: [PATCH] Better + more flexible itemstack merging
|
@ -1,4 +1,4 @@
|
||||
From 79ce6e3a28a745cd7a16498149dc6b66204b211a Mon Sep 17 00:00:00 2001
|
||||
From 116b25dc302af3d7059ee7fc101a570d19362a5f Mon Sep 17 00:00:00 2001
|
||||
From: lishid <lishid@gmail.com>
|
||||
Date: Mon, 21 Jan 2013 16:59:04 +1100
|
||||
Subject: [PATCH] Add oreobfuscator for Spigot.
|
@ -1,4 +1,4 @@
|
||||
From 21495bd89ab6753951d9ca3ac2532d94404ab53e Mon Sep 17 00:00:00 2001
|
||||
From f40330caff1f37825408461fed04b25c91a3a87b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Jan 2013 19:31:14 -0500
|
||||
Subject: [PATCH] Reduce number of LivingEntity collision checks.
|
@ -1,4 +1,4 @@
|
||||
From a92dd621c34cdca2b5c4ceb27ea92dec45129bba Mon Sep 17 00:00:00 2001
|
||||
From b9f3f54e97394c1e2ebeea5add889e9445d073dc Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Fri, 25 Jan 2013 13:15:42 +1100
|
||||
Subject: [PATCH] Track Xray timings.
|
Loading…
Reference in New Issue
Block a user