SPIGOT-5484: Add more spawn tick settings

This commit is contained in:
Phoenix616 2020-03-07 18:30:21 +01:00 committed by md_5
parent 7f61a2526e
commit fc24934098
5 changed files with 79 additions and 20 deletions

View File

@ -83,7 +83,7 @@
public void tick(BooleanSupplier booleansupplier) { public void tick(BooleanSupplier booleansupplier) {
this.world.getMethodProfiler().enter("purge"); this.world.getMethodProfiler().enter("purge");
this.chunkMapDistance.purgeTickets(); this.chunkMapDistance.purgeTickets();
@@ -318,13 +346,13 @@ @@ -318,13 +346,19 @@
this.lastTickTime = i; this.lastTickTime = i;
WorldData worlddata = this.world.getWorldData(); WorldData worlddata = this.world.getWorldData();
boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES; boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES;
@ -95,32 +95,43 @@
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
BlockPosition blockposition = this.world.getSpawn(); BlockPosition blockposition = this.world.getSpawn();
- boolean flag2 = worlddata.getTime() % 400L == 0L; - boolean flag2 = worlddata.getTime() % 400L == 0L;
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks + // CraftBukkit start - Other mob type spawn tick rate
+ boolean spawnAnimalThisTick = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L;
+ boolean spawnMonsterThisTick = world.ticksPerMonsterSpawns != 0L && worlddata.getTime() % world.ticksPerMonsterSpawns == 0L;
+ boolean spawnWaterThisTick = world.ticksPerWaterSpawns != 0L && worlddata.getTime() % world.ticksPerWaterSpawns == 0L;
+ boolean spawnAmbientThisTick = world.ticksPerAmbientSpawns != 0L && worlddata.getTime() % world.ticksPerAmbientSpawns == 0L;
+ boolean flag2 = spawnAnimalThisTick;
+ // CraftBukkit end
this.world.getMethodProfiler().enter("naturalSpawnCount"); this.world.getMethodProfiler().enter("naturalSpawnCount");
int l = this.chunkMapDistance.b(); int l = this.chunkMapDistance.b();
@@ -353,8 +381,30 @@ @@ -353,8 +387,35 @@
for (int j1 = 0; j1 < i1; ++j1) { for (int j1 = 0; j1 < i1; ++j1) {
EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1]; EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1];
+ // CraftBukkit start - Use per-world spawn limits + // CraftBukkit start - Use per-world spawn limits
+ boolean spawnThisTick = true;
+ int limit = enumcreaturetype.b(); + int limit = enumcreaturetype.b();
+ switch (enumcreaturetype) { + switch (enumcreaturetype) {
+ case MONSTER: + case MONSTER:
+ spawnThisTick = spawnMonsterThisTick;
+ limit = world.getWorld().getMonsterSpawnLimit(); + limit = world.getWorld().getMonsterSpawnLimit();
+ break; + break;
+ case CREATURE: + case CREATURE:
+ spawnThisTick = spawnAnimalThisTick;
+ limit = world.getWorld().getAnimalSpawnLimit(); + limit = world.getWorld().getAnimalSpawnLimit();
+ break; + break;
+ case WATER_CREATURE: + case WATER_CREATURE:
+ spawnThisTick = spawnWaterThisTick;
+ limit = world.getWorld().getWaterAnimalSpawnLimit(); + limit = world.getWorld().getWaterAnimalSpawnLimit();
+ break; + break;
+ case AMBIENT: + case AMBIENT:
+ spawnThisTick = spawnAmbientThisTick;
+ limit = world.getWorld().getAmbientSpawnLimit(); + limit = world.getWorld().getAmbientSpawnLimit();
+ break; + break;
+ } + }
+ +
+ if (limit == 0) { + if (!spawnThisTick || limit == 0) {
+ continue; + continue;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -131,7 +142,7 @@
if (object2intmap.getInt(enumcreaturetype) <= k1) { if (object2intmap.getInt(enumcreaturetype) <= k1) {
SpawnerCreature.a(enumcreaturetype, this.world, chunk, blockposition); SpawnerCreature.a(enumcreaturetype, this.world, chunk, blockposition);
@@ -507,12 +557,18 @@ @@ -507,12 +568,18 @@
@Override @Override
protected boolean executeNext() { protected boolean executeNext() {

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();
@@ -40,7 +51,39 @@ @@ -40,7 +51,43 @@
private final WorldBorder worldBorder; private final WorldBorder worldBorder;
private final BiomeManager biomeManager; private final BiomeManager biomeManager;
@ -36,6 +36,8 @@
+ public List<EntityItem> captureDrops; + public List<EntityItem> captureDrops;
+ public long ticksPerAnimalSpawns; + public long ticksPerAnimalSpawns;
+ public long ticksPerMonsterSpawns; + public long ticksPerMonsterSpawns;
+ public long ticksPerWaterSpawns;
+ public long ticksPerAmbientSpawns;
+ public boolean populating; + public boolean populating;
+ +
+ public CraftWorld getWorld() { + public CraftWorld getWorld() {
@ -55,11 +57,13 @@
+ this.world = new CraftWorld((WorldServer) this, gen, env); + this.world = new CraftWorld((WorldServer) this, gen, env);
+ 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.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit
+ // CraftBukkit end + // CraftBukkit end
this.methodProfiler = gameprofilerfiller; this.methodProfiler = gameprofilerfiller;
this.worldData = worlddata; this.worldData = worlddata;
this.worldProvider = dimensionmanager.getWorldProvider(this); this.worldProvider = dimensionmanager.getWorldProvider(this);
@@ -49,6 +92,35 @@ @@ -49,6 +96,35 @@
this.worldBorder = this.worldProvider.getWorldBorder(); this.worldBorder = this.worldProvider.getWorldBorder();
this.serverThread = Thread.currentThread(); this.serverThread = Thread.currentThread();
this.biomeManager = new BiomeManager(this, flag ? worlddata.getSeed() : WorldData.c(worlddata.getSeed()), dimensionmanager.getGenLayerZoomer()); this.biomeManager = new BiomeManager(this, flag ? worlddata.getSeed() : WorldData.c(worlddata.getSeed()), dimensionmanager.getGenLayerZoomer());
@ -95,7 +99,7 @@
} }
@Override @Override
@@ -105,6 +177,17 @@ @@ -105,6 +181,17 @@
@Override @Override
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
@ -113,7 +117,7 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return false; return false;
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
@@ -112,9 +195,22 @@ @@ -112,9 +199,22 @@
} else { } else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition); Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
@ -137,7 +141,7 @@
return false; return false;
} else { } else {
IBlockData iblockdata2 = this.getType(blockposition); IBlockData iblockdata2 = this.getType(blockposition);
@@ -125,6 +221,7 @@ @@ -125,6 +225,7 @@
this.methodProfiler.exit(); this.methodProfiler.exit();
} }
@ -145,7 +149,7 @@
if (iblockdata2 == iblockdata) { if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) { if (iblockdata1 != iblockdata2) {
this.b(blockposition, iblockdata1, iblockdata2); this.b(blockposition, iblockdata1, iblockdata2);
@@ -151,12 +248,65 @@ @@ -151,12 +252,65 @@
this.a(blockposition, iblockdata1, iblockdata2); this.a(blockposition, iblockdata1, iblockdata2);
} }
@ -211,7 +215,7 @@
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
@Override @Override
@@ -195,6 +345,11 @@ @@ -195,6 +349,11 @@
@Override @Override
public void update(BlockPosition blockposition, Block block) { public void update(BlockPosition blockposition, Block block) {
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
@ -223,7 +227,7 @@
this.applyPhysics(blockposition, block); this.applyPhysics(blockposition, block);
} }
@@ -243,6 +398,17 @@ @@ -243,6 +402,17 @@
IBlockData iblockdata = this.getType(blockposition); IBlockData iblockdata = this.getType(blockposition);
try { try {
@ -241,7 +245,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");
@@ -285,6 +451,14 @@ @@ -285,6 +455,14 @@
@Override @Override
public IBlockData getType(BlockPosition blockposition) { public IBlockData getType(BlockPosition blockposition) {
@ -256,7 +260,7 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return Blocks.VOID_AIR.getBlockData(); return Blocks.VOID_AIR.getBlockData();
} else { } else {
@@ -306,11 +480,11 @@ @@ -306,11 +484,11 @@
} }
public boolean isDay() { public boolean isDay() {
@ -270,7 +274,7 @@
} }
@Override @Override
@@ -432,9 +606,11 @@ @@ -432,9 +610,11 @@
TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i);
if (!tileentity1.isRemoved()) { if (!tileentity1.isRemoved()) {
@ -282,7 +286,7 @@
if (this.isLoaded(tileentity1.getPosition())) { if (this.isLoaded(tileentity1.getPosition())) {
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
@@ -442,6 +618,12 @@ @@ -442,6 +622,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);
@ -295,7 +299,7 @@
} }
} }
} }
@@ -606,12 +788,25 @@ @@ -606,12 +792,25 @@
@Nullable @Nullable
@Override @Override
@ -321,7 +325,7 @@
TileEntity tileentity = null; TileEntity tileentity = null;
if (this.tickingTileEntities) { if (this.tickingTileEntities) {
@@ -646,6 +841,13 @@ @@ -646,6 +845,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()) {
@ -335,7 +339,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();
@@ -670,7 +872,7 @@ @@ -670,7 +876,7 @@
} }
public void removeTileEntity(BlockPosition blockposition) { public void removeTileEntity(BlockPosition blockposition) {

View File

@ -639,6 +639,16 @@ public final class CraftServer implements Server {
return this.configuration.getInt("ticks-per.monster-spawns"); return this.configuration.getInt("ticks-per.monster-spawns");
} }
@Override
public int getTicksPerWaterSpawns() {
return this.configuration.getInt("ticks-per.water-spawns");
}
@Override
public int getTicksPerAmbientSpawns() {
return this.configuration.getInt("ticks-per.ambient-spawns");
}
@Override @Override
public PluginManager getPluginManager() { public PluginManager getPluginManager() {
return pluginManager; return pluginManager;
@ -751,6 +761,18 @@ public final class CraftServer implements Server {
} else { } else {
world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns(); world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
} }
if (this.getTicksPerWaterSpawns() < 0) {
world.ticksPerWaterSpawns = 1;
} else {
world.ticksPerWaterSpawns = this.getTicksPerWaterSpawns();
}
if (this.getTicksPerAmbientSpawns() < 0) {
world.ticksPerAmbientSpawns = 1;
} else {
world.ticksPerAmbientSpawns = this.getTicksPerAmbientSpawns();
}
} }
pluginManager.clearPlugins(); pluginManager.clearPlugins();

View File

@ -1920,6 +1920,26 @@ public class CraftWorld implements World {
world.ticksPerMonsterSpawns = ticksPerMonsterSpawns; world.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
} }
@Override
public long getTicksPerWaterSpawns() {
return world.ticksPerWaterSpawns;
}
@Override
public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) {
world.ticksPerWaterSpawns = ticksPerWaterSpawns;
}
@Override
public long getTicksPerAmbientSpawns() {
return world.ticksPerAmbientSpawns;
}
@Override
public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) {
world.ticksPerAmbientSpawns = ticksPerAmbientSpawns;
}
@Override @Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
server.getWorldMetadata().setMetadata(this, metadataKey, newMetadataValue); server.getWorldMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -33,5 +33,7 @@ chunk-gc:
ticks-per: ticks-per:
animal-spawns: 400 animal-spawns: 400
monster-spawns: 1 monster-spawns: 1
water-spawns: 1
ambient-spawns: 1
autosave: 6000 autosave: 6000
aliases: now-in-commands.yml aliases: now-in-commands.yml