Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
18f0f8d1ca
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 312281ea PR-742: Make World implement Keyed CraftBukkit Changes: 2ac7fa7a SPIGOT-7014: getLootTable API should not persistently update loot table 7fdd7941 PR-1046: Make World implement Keyed 7bc728a6 PR-1045: Revert changes to persistence required checks Spigot Changes: b6d12d17 Rebuild patches
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 ccbd0bd60cbc1212d9683667ce4744350eda90bb..1f74b1b2fc9ecfbb83710665ef0171886eab0097 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 8d91f0b8aee459c331ab3777e5e27c9584ff90bd..abd119d2b018c5df0db6a85dbf4a36de897956e2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -222,6 +222,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
|