2021-06-11 14:02:28 +02:00
|
|
|
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
|
2022-06-06 02:17:27 +02:00
|
|
|
index 321dedb7bea65c85aaeac338b88e85c6d453325d..98f81bc3277096493ff0a942361bf79525000431 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-06-06 02:17:27 +02:00
|
|
|
@@ -463,4 +463,15 @@ public class PaperWorldConfig {
|
2021-06-13 16:14:18 +02:00
|
|
|
private void preventMovingIntoUnloadedChunks() {
|
|
|
|
preventMovingIntoUnloadedChunks = getBoolean("prevent-moving-into-unloaded-chunks", false);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2021-06-13 16:14:18 +02:00
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+ 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)");
|
|
|
|
+ }
|
|
|
|
+ }
|
2021-06-13 16:14:18 +02:00
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
2022-05-09 11:03:07 +02:00
|
|
|
index 1603657d75334c0425e737cd661a4ed724333206..6282d5899fe0b78ecbb6236db178c8231f7cd521 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
2022-05-09 11:03:07 +02:00
|
|
|
@@ -86,6 +86,13 @@ public final class NaturalSpawner {
|
2021-06-11 14:02:28 +02:00
|
|
|
MobCategory enumcreaturetype = entity.getType().getCategory();
|
|
|
|
|
|
|
|
if (enumcreaturetype != MobCategory.MISC) {
|
|
|
|
+ // Paper start - Only count natural spawns
|
|
|
|
+ if (!entity.level.paperConfig.countAllMobsForSpawning &&
|
|
|
|
+ !(entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL ||
|
|
|
|
+ entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
BlockPos blockposition = entity.blockPosition();
|
|
|
|
|
2021-11-24 06:44:21 +01:00
|
|
|
chunkSource.query(ChunkPos.asLong(blockposition), (chunk) -> {
|