3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0372-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch

58 Zeilen
2.9 KiB
Diff

From 0000000000000000000000000000000000000000 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 c2cc7b8ebb1b15cf2c080ef5f78c5215d7c20828..bccc2cb3e76aa3ffe1c4200f1b7380d136cb2f96 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -468,6 +468,16 @@ public class PaperWorldConfig {
maxAutoSaveChunksPerTick = getInt("max-auto-save-chunks-per-tick", 24);
}
+ 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)");
+ }
+ }
+
public boolean antiXray;
public EngineMode engineMode;
public int maxChunkSectionIndex;
2020-06-26 01:38:24 +02:00
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 6426f67afb3cc3522ff79b1c8515c1f97cd2f0c1..8130e14b5d6c3e8b0a1234668d5c855e82f3a5dc 100644
2020-06-26 01:38:24 +02:00
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -48,6 +48,13 @@ public final class SpawnerCreature {
2019-07-20 06:01:24 +02:00
EnumCreatureType enumcreaturetype = entity.getEntityType().e();
2020-06-26 01:38:24 +02:00
if (enumcreaturetype != EnumCreatureType.MISC) {
2019-07-20 06:01:24 +02:00
+ // Paper start - Only count natural spawns
2020-06-26 01:38:24 +02:00
+ if (!entity.world.paperConfig.countAllMobsForSpawning &&
+ !(entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL ||
+ entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) {
2019-07-20 06:01:24 +02:00
+ continue;
+ }
+ // Paper end
2020-06-26 01:38:24 +02:00
BlockPosition blockposition = entity.getChunkCoordinates();
long j = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);