2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-11-25 12:20:13 +01:00
|
|
|
index 12f8e5abab4a1f3ab1e1f71746b5bf0b3bf1506c..5d1d042cb2214951025512fa6751ee5899bdd7d7 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
|
2021-11-25 00:26:29 +01:00
|
|
|
@@ -12,6 +12,7 @@ import net.minecraft.world.Difficulty;
|
|
|
|
import net.minecraft.world.entity.EntityType;
|
2021-11-09 08:59:15 +01:00
|
|
|
import net.minecraft.world.entity.monster.Vindicator;
|
|
|
|
import net.minecraft.world.entity.monster.Zombie;
|
|
|
|
+import net.minecraft.world.level.NaturalSpawner;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import org.spigotmc.SpigotWorldConfig;
|
2021-11-25 00:26:29 +01:00
|
|
|
@@ -55,6 +56,11 @@ public class PaperWorldConfig {
|
2021-11-09 08:59:15 +01:00
|
|
|
|
|
|
|
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) {
|
2021-11-25 00:26:29 +01:00
|
|
|
@@ -671,6 +677,21 @@ public class PaperWorldConfig {
|
2021-06-11 14:02:28 +02:00
|
|
|
zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
|
|
|
|
}
|
|
|
|
|
2021-11-09 08:59:15 +01:00
|
|
|
+ public Reference2IntMap<MobCategory> perWorldSpawnLimits = new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ private void perWorldSpawnLimits() {
|
2021-11-09 08:59:15 +01:00
|
|
|
+ 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 : NaturalSpawner.SPAWNING_CATEGORIES) {
|
|
|
|
+ perWorldSpawnLimits.put(value, getInt("spawn-limits." + value.getName(), perWorldSpawnLimits.getInt(value)));
|
|
|
|
+ }
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
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
|
2021-11-25 09:54:06 +01:00
|
|
|
index 8947ecf8136b457265fee897f6d1a3da1ff5ac17..28516df29bfb3d51980e2ace74fa72bfc2151056 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2021-11-09 08:59:15 +01:00
|
|
|
@@ -210,6 +210,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2021-08-25 09:59:26 +02:00
|
|
|
this.biomeProvider = biomeProvider;
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2021-06-15 06:55:46 +02:00
|
|
|
this.environment = env;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - per world spawn limits
|
2021-11-09 08:59:15 +01:00
|
|
|
+ this.monsterSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.MONSTER);
|
|
|
|
+ this.animalSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.CREATURE);
|
|
|
|
+ this.waterAnimalSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.WATER_CREATURE);
|
|
|
|
+ this.waterAmbientSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.WATER_AMBIENT);
|
|
|
|
+ this.ambientSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.AMBIENT);
|
|
|
|
+ this.waterUndergroundCreatureSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.UNDERGROUND_WATER_CREATURE);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|