Paper/Spigot-Server-Patches/0424-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch
Aikar 76d2a4cb8f
Add a config for mob spawn change, really shouldn't use it
turning this to true allows 1 player to deny other players the ability
to have mobs spawn. It really is a bad idea and reverts back to iffy
mob spawn limits where mob farms in the world stops natural spawns
from occuring.

Really recommend resorting to different solutions than ever using this config.
2019-03-24 12:59:28 -04:00

63 Zeilen
2.7 KiB
Diff

From c00cbd11cd310d1b03883c60261ced22e8ae6cae Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 24 Mar 2019 01:01:32 -0400
Subject: [PATCH] Only count Natural Spawned mobs towards natural spawn mob
limit
This resolves the super common complaint about mobs not spawning.
This was ultimately a flaw in the vanilla count algorithim that allows
spawners and other misc mobs to count against the mob limit, which are
not bounded, and can prevent the entire world from spawning new.
I believe Bukkits changes around persistence may of actually made it
worse than vanilla.
This should fully solve all of the issues around it so that only natural
influences natural spawns.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index f259c4e514..fa1d88aa84 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -594,4 +594,14 @@ public class PaperWorldConfig {
log("Using vanilla redstone algorithm.");
}
}
+
+ public boolean countAllMobsForSpawning = false;
+ private void countAllMobsForSpawning() {
+ countAllMobsForSpawning = getBoolean("count-all-mobs-for-spawning", false);
+ if (countAllMobsForSpawning) {
+ log("Counting all mobs for spawning. Mob farms may reduce natural spawns elsewhere in world.");
+ } else {
+ log("Using improved mob spawn limits (Only Natural Spawns impact spawn limits for more natural spawns)");
+ }
+ }
}
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
index a10a5bc138..346176cf98 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
@@ -7,6 +7,7 @@ import net.minecraft.server.IAnimal;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.World;
import net.minecraft.server.WorldServer;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import java.util.ArrayList;
import java.util.Collection;
@@ -90,7 +91,8 @@ public class PaperWorldEntityList extends ArrayList<Entity> {
}
public void updateEntityCount(Entity entity, int amt) {
- if (!(entity instanceof IAnimal)) return;
+ // Only count natural spawns so that mob
+ if (!(entity instanceof IAnimal) || (entity.spawnReason != SpawnReason.NATURAL && !world.paperConfig.countAllMobsForSpawning)) return;
if (entity instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) entity;
--
2.21.0