geforkt von Mirrors/Paper
64 Zeilen
3.2 KiB
Diff
64 Zeilen
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: chase <chasewhip20@gmail.com>
|
|
Date: Wed, 2 Dec 2020 22:43:39 -0800
|
|
Subject: [PATCH] add per world spawn limits
|
|
|
|
Taken from #2982. Credit to Chasewhip8
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index bfd1b59b1bf071c3beedcd6d8db364ed41946033..691e5db143801920a34bc623912c24c9024b97b0 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -58,6 +58,11 @@ public class PaperWorldConfig {
|
|
|
|
set("despawn-ranges.soft", null);
|
|
set("despawn-ranges.hard", null);
|
|
+
|
|
+ set("spawn-limits.monsters", null);
|
|
+ set("spawn-limits.animals", null);
|
|
+ set("spawn-limits.water-animals", null);
|
|
+ set("spawn-limits.water-ambient", null);
|
|
}
|
|
|
|
if (needsSave) {
|
|
@@ -714,6 +719,21 @@ public class PaperWorldConfig {
|
|
zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
|
|
}
|
|
|
|
+ public Reference2IntMap<MobCategory> perWorldSpawnLimits = new Reference2IntOpenHashMap<>(net.minecraft.world.level.NaturalSpawner.SPAWNING_CATEGORIES.length);
|
|
+ private void perWorldSpawnLimits() {
|
|
+ perWorldSpawnLimits.defaultReturnValue(-1);
|
|
+ if (PaperConfig.version < 24) {
|
|
+ // ambient category already had correct name
|
|
+ perWorldSpawnLimits.put(MobCategory.MONSTER, getInt("spawn-limits.monsters", -1, false));
|
|
+ perWorldSpawnLimits.put(MobCategory.CREATURE, getInt("spawn-limits.animals", -1, false));
|
|
+ perWorldSpawnLimits.put(MobCategory.WATER_CREATURE, getInt("spawn-limits.water-animals", -1, false));
|
|
+ perWorldSpawnLimits.put(MobCategory.WATER_AMBIENT, getInt("spawn-limits.water-ambient", -1, false));
|
|
+ }
|
|
+ for (MobCategory value : net.minecraft.world.level.NaturalSpawner.SPAWNING_CATEGORIES) {
|
|
+ perWorldSpawnLimits.put(value, getInt("spawn-limits." + value.getName(), perWorldSpawnLimits.getInt(value)));
|
|
+ }
|
|
+ }
|
|
+
|
|
public int lightQueueSize = 20;
|
|
private void lightQueueSize() {
|
|
lightQueueSize = getInt("light-queue-size", lightQueueSize);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 3dac97ce8f744dc289f4a0555db1a95204287a4a..e84f352280fbdbda194f5b151f942d6d6718dc40 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -221,6 +221,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
this.biomeProvider = biomeProvider;
|
|
|
|
this.environment = env;
|
|
+ // Paper start - per world spawn limits
|
|
+ for (SpawnCategory spawnCategory : SpawnCategory.values()) {
|
|
+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
|
|
+ setSpawnLimit(spawnCategory, this.world.paperConfig.perWorldSpawnLimits.getInt(CraftSpawnCategory.toNMS(spawnCategory)));
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|