#934: Support for configuring Water Underground Creatures spawn settings

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2021-10-05 11:29:52 +11:00
parent f27c8f74f8
commit 2d0a775210
5 changed files with 71 additions and 18 deletions

View File

@@ -22,7 +22,7 @@
continue;
}
}
@@ -108,10 +114,49 @@
@@ -108,10 +114,54 @@
EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES;
int i = aenumcreaturetype.length;
@@ -33,6 +33,7 @@
+ boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterSpawns == 0L;
+ boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAmbientSpawns == 0L;
+ boolean spawnWaterAmbientThisTick = worldserver.ticksPerWaterAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterAmbientSpawns == 0L;
+ boolean spawnWaterUndergroundCreatureThisTick = worldserver.ticksPerWaterUndergroundCreatureSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterUndergroundCreatureSpawns == 0L;
+ // CraftBukkit end
+
for (int j = 0; j < i; ++j) {
@@ -53,6 +54,10 @@
+ spawnThisTick = spawnWaterThisTick;
+ limit = worldserver.getWorld().getWaterAnimalSpawnLimit();
+ break;
+ case UNDERGROUND_WATER_CREATURE:
+ spawnThisTick = spawnWaterUndergroundCreatureThisTick;
+ limit = worldserver.getWorld().getWaterUndergroundCreatureSpawnLimit();
+ break;
+ case AMBIENT:
+ spawnThisTick = spawnAmbientThisTick;
+ limit = worldserver.getWorld().getAmbientSpawnLimit();
@@ -73,7 +78,7 @@
Objects.requireNonNull(spawnercreature_d);
SpawnerCreature.c spawnercreature_c = spawnercreature_d::a;
@@ -196,10 +241,14 @@
@@ -196,10 +246,14 @@
entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F);
if (a(worldserver, entityinsentient, d2)) {
groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
@@ -92,7 +97,7 @@
if (j >= entityinsentient.getMaxSpawnGroup()) {
return;
}
@@ -370,7 +419,7 @@
@@ -370,7 +424,7 @@
if (entityinsentient.a((GeneratorAccess) worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) worldaccess)) {
groupdataentity = entityinsentient.prepare(worldaccess, worldaccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null);
@@ -101,7 +106,7 @@
flag = true;
}
}
@@ -486,8 +535,10 @@
@@ -486,8 +540,10 @@
return this.unmodifiableMobCategoryCounts;
}

View File

@@ -29,7 +29,7 @@
public abstract class World implements GeneratorAccess, AutoCloseable {
protected static final Logger LOGGER = LogManager.getLogger();
@@ -103,7 +125,50 @@
@@ -103,7 +125,52 @@
private final BiomeManager biomeManager;
private final ResourceKey<World> dimension;
@@ -51,6 +51,7 @@
+ public long ticksPerMonsterSpawns;
+ public long ticksPerWaterSpawns;
+ public long ticksPerWaterAmbientSpawns;
+ public long ticksPerWaterUndergroundCreatureSpawns;
+ public long ticksPerAmbientSpawns;
+ public boolean populating;
+
@@ -73,6 +74,7 @@
+ this.ticksPerMonsterSpawns = this.getCraftServer().getTicksPerMonsterSpawns(); // CraftBukkit
+ this.ticksPerWaterSpawns = this.getCraftServer().getTicksPerWaterSpawns(); // CraftBukkit
+ this.ticksPerWaterAmbientSpawns = this.getCraftServer().getTicksPerWaterAmbientSpawns(); // CraftBukkit
+ this.ticksPerWaterUndergroundCreatureSpawns = this.getCraftServer().getTicksPerWaterUndergroundCreatureSpawns(); // CraftBukkit
+ this.ticksPerAmbientSpawns = this.getCraftServer().getTicksPerAmbientSpawns(); // CraftBukkit
+ this.typeKey = (ResourceKey) this.getCraftServer().getHandle().getServer().registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).c(dimensionmanager).orElseThrow(() -> {
+ return new IllegalStateException("Unregistered dimension type: " + dimensionmanager);
@@ -81,7 +83,7 @@
this.profiler = supplier;
this.levelData = worlddatamutable;
this.dimensionType = dimensionmanager;
@@ -113,12 +178,12 @@
@@ -113,12 +180,12 @@
this.worldBorder = new WorldBorder() {
@Override
public double getCenterX() {
@@ -96,7 +98,7 @@
}
};
} else {
@@ -128,6 +193,35 @@
@@ -128,6 +195,35 @@
this.thread = Thread.currentThread();
this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer());
this.isDebug = flag1;
@@ -132,7 +134,7 @@
}
@Override
@@ -185,6 +279,17 @@
@@ -185,6 +281,17 @@
@Override
public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
@@ -150,7 +152,7 @@
if (this.isOutsideWorld(blockposition)) {
return false;
} else if (!this.isClientSide && this.isDebugWorld()) {
@@ -192,9 +297,24 @@
@@ -192,9 +299,24 @@
} else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock();
@@ -176,7 +178,7 @@
return false;
} else {
IBlockData iblockdata2 = this.getType(blockposition);
@@ -205,6 +325,7 @@
@@ -205,6 +327,7 @@
this.getMethodProfiler().exit();
}
@@ -184,7 +186,7 @@
if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) {
this.b(blockposition, iblockdata1, iblockdata2);
@@ -231,12 +352,69 @@
@@ -231,12 +354,69 @@
this.a(blockposition, iblockdata1, iblockdata2);
}
@@ -254,7 +256,7 @@
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
@Override
@@ -326,6 +504,17 @@
@@ -326,6 +506,17 @@
IBlockData iblockdata = this.getType(blockposition);
try {
@@ -272,7 +274,7 @@
iblockdata.doPhysics(this, blockposition, block, blockposition1, false);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
@@ -368,6 +557,14 @@
@@ -368,6 +559,14 @@
@Override
public IBlockData getType(BlockPosition blockposition) {
@@ -287,7 +289,7 @@
if (this.isOutsideWorld(blockposition)) {
return Blocks.VOID_AIR.getBlockData();
} else {
@@ -484,7 +681,17 @@
@@ -484,7 +683,17 @@
@Nullable
@Override
@@ -305,7 +307,7 @@
return this.isOutsideWorld(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAtWorldCoords(blockposition).a(blockposition, Chunk.EnumTileEntityState.IMMEDIATE));
}
@@ -492,6 +699,12 @@
@@ -492,6 +701,12 @@
BlockPosition blockposition = tileentity.getPosition();
if (!this.isOutsideWorld(blockposition)) {
@@ -318,7 +320,7 @@
this.getChunkAtWorldCoords(blockposition).b(tileentity);
}
}
@@ -595,7 +808,7 @@
@@ -595,7 +810,7 @@
for (int j = 0; j < i; ++j) {
EntityComplexPart entitycomplexpart = aentitycomplexpart[j];
@@ -327,7 +329,7 @@
if (t0 != null && predicate.test(t0)) {
list.add(t0);
@@ -921,6 +1134,14 @@
@@ -921,6 +1136,14 @@
public abstract LevelEntityGetter<Entity> getEntities();
protected void a(@Nullable Entity entity, GameEvent gameevent, BlockPosition blockposition, int i) {