@@ -10,7 +10,7 @@ Also has a hover text on each mob category listing what entity types are
1010in said category
1111
1212diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
13- index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f2b7dd452 100644
13+ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..be1da6ebf8c1468182cbb92a16e4866bfb2ecfc3 100644
1414--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
1515+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
1616@@ -3,6 +3,7 @@ package com.destroystokyo.paper;
@@ -213,7 +213,7 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f
213213+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
214214+ sender.sendMessage(this.buildMobcapsComponent(
215215+ category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category),
216- + category -> level.getWorld().getSpawnLimit (org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
216+ + category -> level.getWorld().getSpawnLimitUnsafe (org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
217217+ ));
218218+ }
219219+
@@ -272,19 +272,16 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f
272272 List<org.bukkit.World> worlds;
273273 if (args.length < 2 || args[1].equals("*")) {
274274diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
275- index 8e63d93a574f2c37094770099ea8e1f45cde3db5..ded0c79bcf1f78c6858270c6787aa5baced856b6 100644
275+ index 8e63d93a574f2c37094770099ea8e1f45cde3db5..6dba117b4f5dc6c4e078a32037a4026b45bf2176 100644
276276--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
277277+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
278- @@ -191,6 +191,19 @@ public final class NaturalSpawner {
278+ @@ -191,6 +191,16 @@ public final class NaturalSpawner {
279279 world.getProfiler().pop();
280280 }
281281
282282+ // Paper start
283283+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
284- + if (category == MobCategory.MISC) {
285- + return -1;
286- + }
287- + final int categoryLimit = level.getWorld().getSpawnLimit(CraftSpawnCategory.toBukkit(category));
284+ + final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category));
288285+ if (categoryLimit < 1) {
289286+ return categoryLimit;
290287+ }
@@ -295,6 +292,42 @@ index 8e63d93a574f2c37094770099ea8e1f45cde3db5..ded0c79bcf1f78c6858270c6787aa5ba
295292 // Paper start - add parameters and int ret type
296293 public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
297294 spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
295+ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
296+ index e0e7fb4cc5516d8712f384fb5cb4d22c5bdceff5..51f537069c195edf1b7a60f233997d3cc03d304a 100644
297+ --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
298+ +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
299+ @@ -2145,6 +2145,11 @@ public final class CraftServer implements Server {
300+
301+ @Override
302+ public int getSpawnLimit(SpawnCategory spawnCategory) {
303+ + // Paper start
304+ + return this.getSpawnLimitUnsafe(spawnCategory);
305+ + }
306+ + public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
307+ + // Paper end
308+ return this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
309+ }
310+
311+ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
312+ index 004af6a256e76389234723e0f79634f5a8e26c23..9dd77d989fa6e33ce55525b88fb21a863e156810 100644
313+ --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
314+ +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
315+ @@ -1707,9 +1707,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
316+ Validate.notNull(spawnCategory, "SpawnCategory cannot be null");
317+ Validate.isTrue(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory." + spawnCategory + " are not supported.");
318+
319+ + // Paper start
320+ + return this.getSpawnLimitUnsafe(spawnCategory);
321+ + }
322+ + public final int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
323+ int limit = this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
324+ if (limit < 0) {
325+ - limit = this.server.getSpawnLimit(spawnCategory);
326+ + limit = this.server.getSpawnLimitUnsafe(spawnCategory);
327+ + // Paper end
328+ }
329+ return limit;
330+ }
298331diff --git a/src/test/java/io/papermc/paper/PaperCommandTest.java b/src/test/java/io/papermc/paper/PaperCommandTest.java
299332new file mode 100644
300333index 0000000000000000000000000000000000000000..4b5b368ef17bdb90f50e6ccc1f814cf93c7c0590
0 commit comments