mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
Implement API for ambient mob spawn limit. Add spawn-limit.ambient to
bukkit.yml. Adds BUKKIT-2765
This commit is contained in:
parent
46d7cd1e05
commit
f479aa84a4
4 changed files with 26 additions and 1 deletions
|
@ -69,7 +69,7 @@ public final class SpawnerCreature {
|
|||
EnumCreatureType enumcreaturetype = aenumcreaturetype[j1];
|
||||
|
||||
// CraftBukkit start - use per-world spawn limits
|
||||
int limit = 0;
|
||||
int limit = enumcreaturetype.b();
|
||||
switch (enumcreaturetype) {
|
||||
case MONSTER:
|
||||
limit = worldserver.getWorld().getMonsterSpawnLimit();
|
||||
|
@ -80,6 +80,9 @@ public final class SpawnerCreature {
|
|||
case WATER_CREATURE:
|
||||
limit = worldserver.getWorld().getWaterAnimalSpawnLimit();
|
||||
break;
|
||||
case AMBIENT:
|
||||
limit = worldserver.getWorld().getAmbientSpawnLimit();
|
||||
break;
|
||||
}
|
||||
|
||||
if (limit == 0) {
|
||||
|
|
|
@ -155,6 +155,7 @@ public final class CraftServer implements Server {
|
|||
private int monsterSpawn = -1;
|
||||
private int animalSpawn = -1;
|
||||
private int waterAnimalSpawn = -1;
|
||||
private int ambientSpawn = -1;
|
||||
private File container;
|
||||
private WarningState warningState = WarningState.DEFAULT;
|
||||
|
||||
|
@ -190,6 +191,7 @@ public final class CraftServer implements Server {
|
|||
monsterSpawn = configuration.getInt("spawn-limits.monsters");
|
||||
animalSpawn = configuration.getInt("spawn-limits.animals");
|
||||
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
|
||||
ambientSpawn = configuration.getInt("spawn-limits.ambient");
|
||||
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
||||
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
||||
|
||||
|
@ -526,6 +528,7 @@ public final class CraftServer implements Server {
|
|||
monsterSpawn = configuration.getInt("spawn-limits.monsters");
|
||||
animalSpawn = configuration.getInt("spawn-limits.animals");
|
||||
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
|
||||
ambientSpawn = configuration.getInt("spawn-limits.ambient");
|
||||
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
||||
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
||||
|
||||
|
@ -1236,6 +1239,10 @@ public final class CraftServer implements Server {
|
|||
return waterAnimalSpawn;
|
||||
}
|
||||
|
||||
public int getAmbientSpawnLimit() {
|
||||
return ambientSpawn;
|
||||
}
|
||||
|
||||
public boolean isPrimaryThread() {
|
||||
return Thread.currentThread().equals(console.primaryThread);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class CraftWorld implements World {
|
|||
private int monsterSpawn = -1;
|
||||
private int animalSpawn = -1;
|
||||
private int waterAnimalSpawn = -1;
|
||||
private int ambientSpawn = -1;
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
|
@ -1188,6 +1189,19 @@ public class CraftWorld implements World {
|
|||
waterAnimalSpawn = limit;
|
||||
}
|
||||
|
||||
public int getAmbientSpawnLimit() {
|
||||
if (ambientSpawn < 0) {
|
||||
return server.getAmbientSpawnLimit();
|
||||
}
|
||||
|
||||
return ambientSpawn;
|
||||
}
|
||||
|
||||
public void setAmbientSpawnLimit(int limit) {
|
||||
ambientSpawn = limit;
|
||||
}
|
||||
|
||||
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
if (loc == null || sound == null) return;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ spawn-limits:
|
|||
monsters: 70
|
||||
animals: 15
|
||||
water-animals: 5
|
||||
ambient: 15
|
||||
ticks-per:
|
||||
animal-spawns: 400
|
||||
monster-spawns: 1
|
||||
|
|
Loading…
Reference in a new issue