Make despawn distance configs per-category, improve per category spawn limit config (#6717)

Also adds per-world spawn limit config in paper.yml for `underground_water_creature`, and migrates existing spawn limit config options to their Mojang names.
This commit is contained in:
Jake Potrebic 2021-11-08 23:59:15 -08:00
parent 1f7df1832f
commit 986f5e5d12
11 changed files with 152 additions and 62 deletions

View file

@ -252,3 +252,6 @@ public net.minecraft.world.entity.monster.Zombie supportsBreakDoorGoal()Z
# Add Material#hasCollision # Add Material#hasCollision
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
# add per world spawn limits
public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES

View file

@ -8,25 +8,60 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ package com.destroystokyo.paper;
import java.util.List;
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import net.minecraft.world.entity.MobCategory;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.SpigotWorldConfig;
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
public void removeOldValues() {
boolean needsSave = false;
+ if (PaperConfig.version < 24) {
+ needsSave = true;
+
+ set("despawn-ranges.soft", null);
+ set("despawn-ranges.hard", null);
+ }
+
if (needsSave) {
saveConfig();
}
@@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -0,0 +0,0 @@ public class PaperWorldConfig {
private void nerfedMobsShouldJump() { private void nerfedMobsShouldJump() {
nerfedMobsShouldJump = getBoolean("spawner-nerfed-mobs-should-jump", false); nerfedMobsShouldJump = getBoolean("spawner-nerfed-mobs-should-jump", false);
} }
+ +
+ public int softDespawnDistance; + public final Reference2IntMap<MobCategory> softDespawnDistances = new Reference2IntOpenHashMap<>(MobCategory.values().length);
+ public int hardDespawnDistance; + public final Reference2IntMap<MobCategory> hardDespawnDistances = new Reference2IntOpenHashMap<>(MobCategory.values().length);
+ private void despawnDistances() { + private void despawnDistances() {
+ softDespawnDistance = getInt("despawn-ranges.soft", 32); // 32^2 = 1024, Minecraft Default + if (PaperConfig.version < 24) {
+ hardDespawnDistance = getInt("despawn-ranges.hard", 128); // 128^2 = 16384, Minecraft Default + int softDistance = getInt("despawn-ranges.soft", 32, false); // 32^2 = 1024, Minecraft Default
+ + int hardDistance = getInt("despawn-ranges.hard", 128, false); // 128^2 = 16384, Minecraft Default
+ if (softDespawnDistance > hardDespawnDistance) { + for (MobCategory value : MobCategory.values()) {
+ softDespawnDistance = hardDespawnDistance; + if (softDistance != 32) {
+ softDespawnDistances.put(value, softDistance);
+ }
+ if (hardDistance != 128) {
+ hardDespawnDistances.put(value, hardDistance);
+ }
+ }
+ }
+ for (MobCategory category : MobCategory.values()) {
+ int softDistance = getInt("despawn-ranges." + category.getName() + ".soft", softDespawnDistances.getOrDefault(category, category.getNoDespawnDistance()));
+ int hardDistance = getInt("despawn-ranges." + category.getName() + ".hard", hardDespawnDistances.getOrDefault(category, category.getDespawnDistance()));
+ if (softDistance > hardDistance) {
+ softDistance = hardDistance;
+ }
+ log("Mobs in " + category.getName() + " Despawn Ranges: Soft" + softDistance + " Hard: " + hardDistance);
+ softDespawnDistances.put(category, softDistance);
+ hardDespawnDistances.put(category, hardDistance);
+ } + }
+
+ log("Living Entity Despawn Ranges: Soft: " + softDespawnDistance + " Hard: " + hardDespawnDistance);
+
+ softDespawnDistance = softDespawnDistance*softDespawnDistance;
+ hardDespawnDistance = hardDespawnDistance*hardDespawnDistance;
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
@ -34,22 +69,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity {
int i = this.getType().getCategory().getDespawnDistance();
if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this); // CraftBukkit - decompile error
- int i = this.getType().getCategory().getDespawnDistance();
+ int i = this.level.paperConfig.hardDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances
int j = i * i; int j = i * i;
- if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check
+ if (d0 > (double) level.paperConfig.hardDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances
this.discard(); this.discard();
} }
int k = this.getType().getCategory().getNoDespawnDistance(); - int k = this.getType().getCategory().getNoDespawnDistance();
+ int k = this.level.paperConfig.softDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances
int l = k * k; int l = k * k;
- if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
+ if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > level.paperConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances
this.discard();
- } else if (d0 < (double) l) {
+ } else if (d0 < level.paperConfig.softDespawnDistance) { // Paper - custom despawn distances
this.noActionTime = 0;
}
}

View file

@ -84,8 +84,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
commands.put("paper", new PaperCommand("paper")); commands.put("paper", new PaperCommand("paper"));
+ commands.put("mspt", new MSPTCommand("mspt")); + commands.put("mspt", new MSPTCommand("mspt"));
version = getInt("config-version", 23); version = getInt("config-version", 24);
set("config-version", 23); set("config-version", 24);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java

View file

@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -0,0 +0,0 @@ public class PaperWorldConfig {
softDespawnDistance = softDespawnDistance*softDespawnDistance; hardDespawnDistances.put(category, hardDistance);
hardDespawnDistance = hardDespawnDistance*hardDespawnDistance; }
} }
+ +
+ public boolean keepSpawnInMemory; + public boolean keepSpawnInMemory;

View file

@ -14,6 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.util.Arrays; +import java.util.Arrays;
import java.util.List; import java.util.List;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import net.minecraft.world.entity.MobCategory;
+import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode; +import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View file

@ -8,11 +8,10 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ package com.destroystokyo.paper; @@ -0,0 +0,0 @@ import java.util.List;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import java.util.Arrays; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import java.util.List; import net.minecraft.world.entity.MobCategory;
-
+import java.util.stream.Collectors; +import java.util.stream.Collectors;
+import net.minecraft.world.Difficulty; +import net.minecraft.world.Difficulty;
+import net.minecraft.world.entity.monster.Vindicator; +import net.minecraft.world.entity.monster.Vindicator;

View file

@ -12,12 +12,11 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@ import java.util.List;
package com.destroystokyo.paper; import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import java.util.Arrays; import net.minecraft.world.entity.MobCategory;
+import java.util.HashMap; +import java.util.HashMap;
import java.util.List;
+import java.util.Map; +import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.world.Difficulty; import net.minecraft.world.Difficulty;

View file

@ -226,7 +226,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
- Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.affectsSpawning); // Paper - Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.affectsSpawning); // Paper
+ // Paper start - optimise checkDespawn + // Paper start - optimise checkDespawn
+ Player entityhuman = this.level.findNearbyPlayer(this, level.paperConfig.hardDespawnDistance + 1, EntitySelector.affectsSpawning); // Paper + Player entityhuman = this.level.findNearbyPlayer(this, level.paperConfig.hardDespawnDistances.getInt(this.getType().getCategory()) + 1, EntitySelector.affectsSpawning); // Paper
+ if (entityhuman == null) { + if (entityhuman == null) {
+ entityhuman = ((ServerLevel)this.level).playersAffectingSpawning.isEmpty() ? null : ((ServerLevel)this.level).playersAffectingSpawning.get(0); + entityhuman = ((ServerLevel)this.level).playersAffectingSpawning.isEmpty() ? null : ((ServerLevel)this.level).playersAffectingSpawning.get(0);
+ } + }

View file

@ -364,8 +364,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ commands = new HashMap<String, Command>(); + commands = new HashMap<String, Command>();
+ commands.put("paper", new PaperCommand("paper")); + commands.put("paper", new PaperCommand("paper"));
+ +
+ version = getInt("config-version", 23); + version = getInt("config-version", 24);
+ set("config-version", 23); + set("config-version", 24);
+ readConfig(PaperConfig.class, null); + readConfig(PaperConfig.class, null);
+ } + }
+ +
@ -405,7 +405,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ } + }
+ saveConfig();
+ }
+ +
+ static void saveConfig() {
+ try { + try {
+ config.save(CONFIG_FILE); + config.save(CONFIG_FILE);
+ } catch (IOException ex) { + } catch (IOException ex) {
@ -503,6 +506,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import static com.destroystokyo.paper.PaperConfig.log; +import static com.destroystokyo.paper.PaperConfig.log;
+import static com.destroystokyo.paper.PaperConfig.logError; +import static com.destroystokyo.paper.PaperConfig.logError;
+import static com.destroystokyo.paper.PaperConfig.saveConfig;
+ +
+public class PaperWorldConfig { +public class PaperWorldConfig {
+ +
@ -531,6 +535,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ +
+ public void removeOldValues() {
+ boolean needsSave = false;
+
+ if (needsSave) {
+ saveConfig();
+ }
+ }
+
+ private boolean getBoolean(String path, boolean def) { + private boolean getBoolean(String path, boolean def) {
+ config.addDefault("world-settings.default." + path, def); + config.addDefault("world-settings.default." + path, def);
+ return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path)); + return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
@ -542,8 +554,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ private int getInt(String path, int def) { + private int getInt(String path, int def) {
+ config.addDefault("world-settings.default." + path, def); + return getInt(path, def, true);
+ return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path)); + }
+
+ private int getInt(String path, int def, boolean setDefault) {
+ if (setDefault) {
+ config.addDefault("world-settings.default." + path, def);
+ }
+ return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path, def));
+ } + }
+ +
+ private long getLong(String path, long def) { + private long getLong(String path, long def) {
@ -604,6 +622,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionType>> worlds) { // CraftBukkit public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionType>> worlds) { // CraftBukkit
Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit
WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, worlds, eraseCache); WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, worlds, eraseCache);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
this.forceDifficulty();
for (ServerLevel worldserver : this.getAllLevels()) {
+ worldserver.paperConfig.removeOldValues(); // Paper - callback for clearing old config options, after any migrations have taken place
this.loadSpawn(worldserver.getChunkSource().chunkMap.progressListener, worldserver);
worldserver.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java

View file

@ -31,10 +31,10 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ package com.destroystokyo.paper; @@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import java.util.Arrays; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import net.minecraft.world.entity.MobCategory;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
+import java.util.Locale; +import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -44,8 +44,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.world.Difficulty; import net.minecraft.world.Difficulty;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vindicator; import net.minecraft.world.entity.monster.Vindicator;
import net.minecraft.world.entity.monster.Zombie; @@ -0,0 +0,0 @@ import net.minecraft.world.entity.monster.Zombie;
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode; import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
import net.minecraft.world.level.NaturalSpawner;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
+import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View file

@ -9,21 +9,43 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vindicator;
import net.minecraft.world.entity.monster.Zombie;
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
+import net.minecraft.world.level.NaturalSpawner;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.SpigotWorldConfig;
@@ -0,0 +0,0 @@ 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) {
@@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -0,0 +0,0 @@ public class PaperWorldConfig {
zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance); zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
} }
+ public int spawnLimitMonsters = -1; + public Reference2IntMap<MobCategory> perWorldSpawnLimits = new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length);
+ public int spawnLimitAnimals = -1;
+ public int spawnLimitWaterAnimals = -1;
+ public int spawnLimitWaterAmbient = -1;
+ public int spawnLimitAmbient = -1;
+ private void perWorldSpawnLimits() { + private void perWorldSpawnLimits() {
+ spawnLimitMonsters = getInt("spawn-limits.monsters", spawnLimitMonsters); + perWorldSpawnLimits.defaultReturnValue(-1);
+ spawnLimitAnimals = getInt("spawn-limits.animals", spawnLimitAnimals); + if (PaperConfig.version < 24) {
+ spawnLimitWaterAnimals = getInt("spawn-limits.water-animals", spawnLimitWaterAnimals); + // ambient category already had correct name
+ spawnLimitWaterAmbient = getInt("spawn-limits.water-ambient", spawnLimitWaterAmbient); + perWorldSpawnLimits.put(MobCategory.MONSTER, getInt("spawn-limits.monsters", -1, false));
+ spawnLimitAmbient = getInt("spawn-limits.ambient", spawnLimitAmbient); + 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)));
+ }
+ } + }
+ +
public int lightQueueSize = 20; public int lightQueueSize = 20;
@ -38,11 +60,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.environment = env; this.environment = env;
+ // Paper start - per world spawn limits + // Paper start - per world spawn limits
+ this.monsterSpawn = this.world.paperConfig.spawnLimitMonsters; + this.monsterSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.MONSTER);
+ this.animalSpawn = this.world.paperConfig.spawnLimitAnimals; + this.animalSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.CREATURE);
+ this.waterAnimalSpawn = this.world.paperConfig.spawnLimitWaterAnimals; + this.waterAnimalSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.WATER_CREATURE);
+ this.waterAmbientSpawn = this.world.paperConfig.spawnLimitWaterAmbient; + this.waterAmbientSpawn = this.world.paperConfig.perWorldSpawnLimits.getInt(net.minecraft.world.entity.MobCategory.WATER_AMBIENT);
+ this.ambientSpawn = this.world.paperConfig.spawnLimitAmbient; + 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);
+ // Paper end + // Paper end
} }