Add configuration options for water_ambient spawning

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2020-06-26 18:39:42 +10:00
parent b60f49f0ea
commit 8144dfbd7f
5 changed files with 71 additions and 18 deletions

View File

@ -21,7 +21,7 @@
continue; continue;
} }
} }
@@ -70,10 +75,44 @@ @@ -70,10 +75,49 @@
EnumCreatureType[] aenumcreaturetype = SpawnerCreature.c; EnumCreatureType[] aenumcreaturetype = SpawnerCreature.c;
int i = aenumcreaturetype.length; int i = aenumcreaturetype.length;
@ -31,6 +31,7 @@
+ boolean spawnMonsterThisTick = worldserver.ticksPerMonsterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerMonsterSpawns == 0L; + boolean spawnMonsterThisTick = worldserver.ticksPerMonsterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerMonsterSpawns == 0L;
+ boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterSpawns == 0L; + boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterSpawns == 0L;
+ boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAmbientSpawns == 0L; + boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAmbientSpawns == 0L;
+ boolean spawnWaterAmbientThisTick = worldserver.ticksPerWaterAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterAmbientSpawns == 0L;
+ // CraftBukkit end + // CraftBukkit end
+ +
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
@ -55,6 +56,10 @@
+ spawnThisTick = spawnAmbientThisTick; + spawnThisTick = spawnAmbientThisTick;
+ limit = worldserver.getWorld().getAmbientSpawnLimit(); + limit = worldserver.getWorld().getAmbientSpawnLimit();
+ break; + break;
+ case WATER_AMBIENT:
+ spawnThisTick = spawnWaterAmbientThisTick;
+ limit = worldserver.getWorld().getWaterAmbientSpawnLimit();
+ break;
+ } + }
- if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype)) { - if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype)) {
@ -67,7 +72,7 @@
a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> { a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> {
return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess); return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess);
}, (entityinsentient, ichunkaccess) -> { }, (entityinsentient, ichunkaccess) -> {
@@ -148,10 +187,13 @@ @@ -148,10 +192,13 @@
entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F);
if (a(worldserver, entityinsentient, d2)) { if (a(worldserver, entityinsentient, d2)) {
groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
@ -85,7 +90,7 @@
if (j >= entityinsentient.getMaxSpawnGroup()) { if (j >= entityinsentient.getMaxSpawnGroup()) {
return; return;
} }
@@ -333,7 +375,7 @@ @@ -333,7 +380,7 @@
if (entityinsentient.a(generatoraccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) generatoraccess)) { if (entityinsentient.a(generatoraccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) generatoraccess)) {
groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null);
@ -94,7 +99,7 @@
flag = true; flag = true;
} }
} }
@@ -458,8 +500,10 @@ @@ -458,8 +505,10 @@
return this.d; return this.d;
} }

View File

@ -18,7 +18,7 @@
public abstract class World implements GeneratorAccess, AutoCloseable { public abstract class World implements GeneratorAccess, AutoCloseable {
protected static final Logger LOGGER = LogManager.getLogger(); protected static final Logger LOGGER = LogManager.getLogger();
@@ -46,7 +57,39 @@ @@ -46,7 +57,41 @@
private final ResourceKey<World> dimensionKey; private final ResourceKey<World> dimensionKey;
private final ResourceKey<DimensionManager> typeKey; private final ResourceKey<DimensionManager> typeKey;
@ -37,6 +37,7 @@
+ public long ticksPerAnimalSpawns; + public long ticksPerAnimalSpawns;
+ public long ticksPerMonsterSpawns; + public long ticksPerMonsterSpawns;
+ public long ticksPerWaterSpawns; + public long ticksPerWaterSpawns;
+ public long ticksPerWaterAmbientSpawns;
+ public long ticksPerAmbientSpawns; + public long ticksPerAmbientSpawns;
+ public boolean populating; + public boolean populating;
+ +
@ -54,12 +55,13 @@
+ this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit + this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
+ this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit + this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
+ this.ticksPerWaterSpawns = this.getServer().getTicksPerWaterSpawns(); // CraftBukkit + this.ticksPerWaterSpawns = this.getServer().getTicksPerWaterSpawns(); // CraftBukkit
+ this.ticksPerWaterAmbientSpawns = this.getServer().getTicksPerWaterAmbientSpawns(); // CraftBukkit
+ this.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit + this.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit
+ // CraftBukkit end + // CraftBukkit end
this.methodProfiler = supplier; this.methodProfiler = supplier;
this.worldData = worlddatamutable; this.worldData = worlddatamutable;
this.x = dimensionmanager; this.x = dimensionmanager;
@@ -57,12 +100,12 @@ @@ -57,12 +102,12 @@
this.worldBorder = new WorldBorder() { this.worldBorder = new WorldBorder() {
@Override @Override
public double getCenterX() { public double getCenterX() {
@ -74,7 +76,7 @@
} }
}; };
} else { } else {
@@ -72,6 +115,35 @@ @@ -72,6 +117,35 @@
this.serverThread = Thread.currentThread(); this.serverThread = Thread.currentThread();
this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer()); this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer());
this.debugWorld = flag1; this.debugWorld = flag1;
@ -110,7 +112,7 @@
} }
@Override @Override
@@ -176,6 +248,17 @@ @@ -176,6 +250,17 @@
@Override @Override
public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
@ -128,7 +130,7 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return false; return false;
} else if (!this.isClientSide && this.isDebugWorld()) { } else if (!this.isClientSide && this.isDebugWorld()) {
@@ -183,9 +266,24 @@ @@ -183,9 +268,24 @@
} else { } else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition); Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
@ -154,7 +156,7 @@
return false; return false;
} else { } else {
IBlockData iblockdata2 = this.getType(blockposition); IBlockData iblockdata2 = this.getType(blockposition);
@@ -196,6 +294,7 @@ @@ -196,6 +296,7 @@
this.getMethodProfiler().exit(); this.getMethodProfiler().exit();
} }
@ -162,7 +164,7 @@
if (iblockdata2 == iblockdata) { if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) { if (iblockdata1 != iblockdata2) {
this.b(blockposition, iblockdata1, iblockdata2); this.b(blockposition, iblockdata1, iblockdata2);
@@ -222,12 +321,65 @@ @@ -222,12 +323,65 @@
this.a(blockposition, iblockdata1, iblockdata2); this.a(blockposition, iblockdata1, iblockdata2);
} }
@ -228,7 +230,7 @@
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
@Override @Override
@@ -309,6 +461,17 @@ @@ -309,6 +463,17 @@
IBlockData iblockdata = this.getType(blockposition); IBlockData iblockdata = this.getType(blockposition);
try { try {
@ -246,7 +248,7 @@
iblockdata.doPhysics(this, blockposition, block, blockposition1, false); iblockdata.doPhysics(this, blockposition, block, blockposition1, false);
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
@@ -351,6 +514,14 @@ @@ -351,6 +516,14 @@
@Override @Override
public IBlockData getType(BlockPosition blockposition) { public IBlockData getType(BlockPosition blockposition) {
@ -261,7 +263,7 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return Blocks.VOID_AIR.getBlockData(); return Blocks.VOID_AIR.getBlockData();
} else { } else {
@@ -498,9 +669,11 @@ @@ -498,9 +671,11 @@
TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i);
if (!tileentity1.isRemoved()) { if (!tileentity1.isRemoved()) {
@ -273,7 +275,7 @@
if (this.isLoaded(tileentity1.getPosition())) { if (this.isLoaded(tileentity1.getPosition())) {
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
@@ -508,6 +681,12 @@ @@ -508,6 +683,12 @@
chunk.setTileEntity(tileentity1.getPosition(), tileentity1); chunk.setTileEntity(tileentity1.getPosition(), tileentity1);
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@ -286,7 +288,7 @@
} }
} }
} }
@@ -548,12 +727,25 @@ @@ -548,12 +729,25 @@
@Nullable @Nullable
@Override @Override
@ -312,7 +314,7 @@
TileEntity tileentity = null; TileEntity tileentity = null;
if (this.tickingTileEntities) { if (this.tickingTileEntities) {
@@ -588,6 +780,13 @@ @@ -588,6 +782,13 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
if (!isOutsideWorld(blockposition)) { if (!isOutsideWorld(blockposition)) {
if (tileentity != null && !tileentity.isRemoved()) { if (tileentity != null && !tileentity.isRemoved()) {
@ -326,7 +328,7 @@
if (this.tickingTileEntities) { if (this.tickingTileEntities) {
tileentity.setLocation(this, blockposition); tileentity.setLocation(this, blockposition);
Iterator iterator = this.tileEntityListPending.iterator(); Iterator iterator = this.tileEntityListPending.iterator();
@@ -612,7 +811,7 @@ @@ -612,7 +813,7 @@
} }
public void removeTileEntity(BlockPosition blockposition) { public void removeTileEntity(BlockPosition blockposition) {

View File

@ -245,6 +245,7 @@ public final class CraftServer implements Server {
private int monsterSpawn = -1; private int monsterSpawn = -1;
private int animalSpawn = -1; private int animalSpawn = -1;
private int waterAnimalSpawn = -1; private int waterAnimalSpawn = -1;
private int waterAmbientSpawn = -1;
private int ambientSpawn = -1; private int ambientSpawn = -1;
private File container; private File container;
private WarningState warningState = WarningState.DEFAULT; private WarningState warningState = WarningState.DEFAULT;
@ -331,6 +332,7 @@ public final class CraftServer implements Server {
monsterSpawn = configuration.getInt("spawn-limits.monsters"); monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals"); animalSpawn = configuration.getInt("spawn-limits.animals");
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
waterAmbientSpawn = configuration.getInt("spawn-limits.water-ambient");
ambientSpawn = configuration.getInt("spawn-limits.ambient"); ambientSpawn = configuration.getInt("spawn-limits.ambient");
console.autosavePeriod = configuration.getInt("ticks-per.autosave"); console.autosavePeriod = configuration.getInt("ticks-per.autosave");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
@ -669,6 +671,11 @@ public final class CraftServer implements Server {
return this.configuration.getInt("ticks-per.water-spawns"); return this.configuration.getInt("ticks-per.water-spawns");
} }
@Override
public int getTicksPerWaterAmbientSpawns() {
return this.configuration.getInt("ticks-per.water-ambient-spawns");
}
@Override @Override
public int getTicksPerAmbientSpawns() { public int getTicksPerAmbientSpawns() {
return this.configuration.getInt("ticks-per.ambient-spawns"); return this.configuration.getInt("ticks-per.ambient-spawns");
@ -752,6 +759,7 @@ public final class CraftServer implements Server {
monsterSpawn = configuration.getInt("spawn-limits.monsters"); monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals"); animalSpawn = configuration.getInt("spawn-limits.animals");
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
waterAmbientSpawn = configuration.getInt("spawn-limits.water-ambient");
ambientSpawn = configuration.getInt("spawn-limits.ambient"); ambientSpawn = configuration.getInt("spawn-limits.ambient");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
TicketType.PLUGIN.loadPeriod = configuration.getInt("chunk-gc.period-in-ticks"); TicketType.PLUGIN.loadPeriod = configuration.getInt("chunk-gc.period-in-ticks");
@ -792,6 +800,12 @@ public final class CraftServer implements Server {
world.ticksPerWaterSpawns = this.getTicksPerWaterSpawns(); world.ticksPerWaterSpawns = this.getTicksPerWaterSpawns();
} }
if (this.getTicksPerWaterAmbientSpawns() < 0) {
world.ticksPerWaterAmbientSpawns = 1;
} else {
world.ticksPerWaterAmbientSpawns = this.getTicksPerWaterAmbientSpawns();
}
if (this.getTicksPerAmbientSpawns() < 0) { if (this.getTicksPerAmbientSpawns() < 0) {
world.ticksPerAmbientSpawns = 1; world.ticksPerAmbientSpawns = 1;
} else { } else {
@ -1647,6 +1661,11 @@ public final class CraftServer implements Server {
return waterAnimalSpawn; return waterAnimalSpawn;
} }
@Override
public int getWaterAmbientSpawnLimit() {
return waterAmbientSpawn;
}
@Override @Override
public int getAmbientSpawnLimit() { public int getAmbientSpawnLimit() {
return ambientSpawn; return ambientSpawn;

View File

@ -277,6 +277,7 @@ public class CraftWorld implements World {
private int monsterSpawn = -1; private int monsterSpawn = -1;
private int animalSpawn = -1; private int animalSpawn = -1;
private int waterAnimalSpawn = -1; private int waterAnimalSpawn = -1;
private int waterAmbientSpawn = -1;
private int ambientSpawn = -1; private int ambientSpawn = -1;
private static final Random rand = new Random(); private static final Random rand = new Random();
@ -1944,6 +1945,16 @@ public class CraftWorld implements World {
world.ticksPerWaterSpawns = ticksPerWaterSpawns; world.ticksPerWaterSpawns = ticksPerWaterSpawns;
} }
@Override
public long getTicksPerWaterAmbientSpawns() {
return world.ticksPerWaterAmbientSpawns;
}
@Override
public void setTicksPerWaterAmbientSpawns(int ticksPerWaterAmbientSpawns) {
world.ticksPerWaterAmbientSpawns = ticksPerWaterAmbientSpawns;
}
@Override @Override
public long getTicksPerAmbientSpawns() { public long getTicksPerAmbientSpawns() {
return world.ticksPerAmbientSpawns; return world.ticksPerAmbientSpawns;
@ -2016,6 +2027,20 @@ public class CraftWorld implements World {
waterAnimalSpawn = limit; waterAnimalSpawn = limit;
} }
@Override
public int getWaterAmbientSpawnLimit() {
if (waterAmbientSpawn < 0) {
return server.getWaterAmbientSpawnLimit();
}
return waterAmbientSpawn;
}
@Override
public void setWaterAmbientSpawnLimit(int limit) {
waterAmbientSpawn = limit;
}
@Override @Override
public int getAmbientSpawnLimit() { public int getAmbientSpawnLimit() {
if (ambientSpawn < 0) { if (ambientSpawn < 0) {

View File

@ -27,6 +27,7 @@ spawn-limits:
monsters: 70 monsters: 70
animals: 10 animals: 10
water-animals: 15 water-animals: 15
water-ambient: 20
ambient: 15 ambient: 15
chunk-gc: chunk-gc:
period-in-ticks: 600 period-in-ticks: 600
@ -34,6 +35,7 @@ ticks-per:
animal-spawns: 400 animal-spawns: 400
monster-spawns: 1 monster-spawns: 1
water-spawns: 1 water-spawns: 1
water-ambient-spawns: 1
ambient-spawns: 1 ambient-spawns: 1
autosave: 6000 autosave: 6000
aliases: now-in-commands.yml aliases: now-in-commands.yml