PaperMC/nms-patches/ChunkProviderServer.patch

79 lines
4.3 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
2019-04-23 04:00:00 +02:00
@@ -82,7 +82,7 @@
2019-04-23 04:00:00 +02:00
if (flag1) {
completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag);
- this.serverThreadQueue.c(completablefuture::isDone);
+ this.serverThreadQueue.c((BooleanSupplier) completablefuture::isDone); // CraftBukkit - decompile error
} else {
completablefuture = CompletableFuture.supplyAsync(() -> {
return this.getChunkFutureMainThread(i, j, chunkstatus, flag);
@@ -193,6 +193,17 @@
this.playerChunkMap.close();
2018-07-15 02:00:00 +02:00
}
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start - modelled on below
+ public void purgeUnload() {
+ this.world.getMethodProfiler().enter("purge");
+ this.chunkMapDistance.purgeTickets();
+ this.tickDistanceManager();
+ this.world.getMethodProfiler().exitEnter("unload");
+ this.playerChunkMap.unloadChunks(() -> true);
+ this.world.getMethodProfiler().exit();
2018-08-26 04:00:00 +02:00
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
public void tick(BooleanSupplier booleansupplier) {
this.world.getMethodProfiler().enter("purge");
this.chunkMapDistance.purgeTickets();
@@ -211,14 +222,14 @@
this.lastTickTime = i;
WorldData worlddata = this.world.getWorldData();
boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES;
- boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning");
+ boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning") && !world.getPlayers().isEmpty(); // CraftBukkit
2019-04-23 04:00:00 +02:00
if (!flag) {
this.world.getMethodProfiler().enter("pollingChunks");
int k = this.chunkMapDistance.b();
int l = this.world.getGameRules().c("randomTickSpeed");
BlockPosition blockposition = this.world.getSpawn();
- boolean flag2 = worlddata.getTime() % 400L == 0L;
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
Object2IntMap<EnumCreatureType> object2intmap = this.world.l();
ObjectBidirectionalIterator objectbidirectionaliterator = this.playerChunkMap.f();
@@ -244,8 +255,30 @@
for (int j1 = 0; j1 < i1; ++j1) {
EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1];
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start - Use per-world spawn limits
+ int limit = enumcreaturetype.b();
+ switch (enumcreaturetype) {
+ case MONSTER:
+ limit = world.getWorld().getMonsterSpawnLimit();
+ break;
+ case CREATURE:
+ limit = world.getWorld().getAnimalSpawnLimit();
+ break;
+ case WATER_CREATURE:
+ limit = world.getWorld().getWaterAnimalSpawnLimit();
+ break;
+ case AMBIENT:
+ limit = world.getWorld().getAmbientSpawnLimit();
+ break;
+ }
+
2019-04-23 04:00:00 +02:00
+ if (limit == 0) {
+ continue;
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) {
- int k1 = enumcreaturetype.b() * k / ChunkProviderServer.b;
+ int k1 = limit * k / ChunkProviderServer.b; // CraftBukkit - use per-world limits
if (object2intmap.getInt(enumcreaturetype) <= k1) {
SpawnerCreature.a(enumcreaturetype, (World) this.world, chunk, blockposition);