2018-07-27 05:57:31 +02:00
|
|
|
From a95213605057d27a9ab8ec79291e1354cee01106 Mon Sep 17 00:00:00 2001
|
2016-04-15 03:03:57 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Thu, 14 Apr 2016 21:01:39 -0400
|
|
|
|
Subject: [PATCH] Fix Bugs with Spigot Mob Spawn Logic
|
|
|
|
|
|
|
|
Spigot drastically altered vanilla mob spawn logic and caused a few issues.
|
|
|
|
1) Used only spawnable chunks vs entire world for entity counting, resulting in ignoring
|
|
|
|
other entities in the world, and causing the world to go over its intended limit.
|
|
|
|
|
|
|
|
Specially with servers using smaller mob spawn ranges than view distance, as well as affects spawning API
|
|
|
|
|
|
|
|
2) Spigot was using 16x16 division instead of vanilla 17x17 division.
|
|
|
|
|
|
|
|
This patch returns mob counting to use all loaded chunks, and 17x17 division.
|
|
|
|
|
2016-04-16 03:31:12 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2018-07-27 05:57:31 +02:00
|
|
|
index e9a44098d9..6c86d3b6bc 100644
|
2016-04-16 03:31:12 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2018-07-15 08:44:37 +02:00
|
|
|
@@ -714,8 +714,8 @@ public class Chunk {
|
2016-04-16 03:31:12 +02:00
|
|
|
i = this.entitySlices.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.entitySlices[i].remove(entity);
|
2018-07-15 08:44:37 +02:00
|
|
|
// Paper start
|
|
|
|
+ if (!this.entitySlices[i].remove(entity)) { return; }
|
|
|
|
entity.setCurrentChunk(null);
|
2018-07-27 05:57:31 +02:00
|
|
|
entityCounts.decrement(entity.getMinecraftKeyString());
|
2016-04-16 03:31:12 +02:00
|
|
|
if (entity instanceof EntityItem) {
|
2016-04-15 03:03:57 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
2018-07-27 05:57:31 +02:00
|
|
|
index 45a83ae995..ed22607d91 100644
|
2016-04-15 03:03:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
2016-07-16 00:36:53 +02:00
|
|
|
@@ -23,6 +23,15 @@ public final class SpawnerCreature {
|
2016-04-15 03:03:57 +02:00
|
|
|
// Spigot start - get entity count only from chunks being processed in b
|
|
|
|
private int getEntityCount(WorldServer server, Class oClass)
|
|
|
|
{
|
|
|
|
+ // Paper start - use entire world, not just active chunks. Spigot broke vanilla expectations.
|
|
|
|
+ if (true) {
|
2018-07-10 07:06:09 +02:00
|
|
|
+ int sum = 0;
|
|
|
|
+ for (Chunk c : server.getChunkProviderServer().chunks.values()) {
|
|
|
|
+ sum += c.entityCount.get(oClass);
|
|
|
|
+ }
|
|
|
|
+ return sum;
|
2016-04-15 03:03:57 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
int i = 0;
|
|
|
|
Iterator<Long> it = this.b.iterator();
|
|
|
|
while ( it.hasNext() )
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -126,7 +135,7 @@ public final class SpawnerCreature {
|
2016-04-15 03:03:57 +02:00
|
|
|
int l1 = limit * i / a; // CraftBukkit - use per-world limits
|
|
|
|
*/ // Paper end
|
|
|
|
|
|
|
|
- if ((mobcnt = getEntityCount(worldserver, enumcreaturetype.a())) <= limit * i / 256) {
|
|
|
|
+ if ((mobcnt = getEntityCount(worldserver, enumcreaturetype.a())) <= limit * i / 289) { // Paper - use 17x17 like vanilla (a at top of file)
|
|
|
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
|
|
|
Iterator iterator1 = this.b.iterator();
|
|
|
|
|
|
|
|
--
|
2018-07-04 09:55:24 +02:00
|
|
|
2.18.0
|
2016-04-15 03:03:57 +02:00
|
|
|
|