mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 00:30:25 +01:00
Fix Bugs with Spigot Mob Spawn Logic - Fixes #138
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. Issues got worse in 1.9 due to more chunks being loaded due to 1.9 changes, that fall out of the monster spawn radius. This patch returns mob counting to use all loaded chunks, and 17x17 division.
This commit is contained in:
parent
794a848857
commit
77cdcc281b
1 changed files with 47 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
From 8ff5e997fd6df8487be017803e257e0b664e4886 Mon Sep 17 00:00:00 2001
|
||||
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.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
index 15a0ce9..b47feb2 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
@@ -21,6 +21,15 @@ public final class SpawnerCreature {
|
||||
// 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) {
|
||||
+ return server
|
||||
+ .getChunkProviderServer()
|
||||
+ .chunks.values()
|
||||
+ .stream()
|
||||
+ .collect(java.util.stream.Collectors.summingInt(c -> c.entityCount.get(oClass)));
|
||||
+ }
|
||||
+ // Paper end
|
||||
int i = 0;
|
||||
Iterator<Long> it = this.b.iterator();
|
||||
while ( it.hasNext() )
|
||||
@@ -126,7 +135,7 @@ public final class SpawnerCreature {
|
||||
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();
|
||||
|
||||
--
|
||||
2.8.1
|
||||
|
Loading…
Reference in a new issue