Fix PaperTickList (#6241)

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke 2021-07-21 19:12:24 +02:00
parent 4ca56ff079
commit 985e42705e
2 changed files with 30 additions and 5 deletions

View File

@ -113,6 +113,7 @@ public net.minecraft.server.level.ChunkMap mainThreadMailbox # todo one of these
# Optimise TickListServer # Optimise TickListServer
public net.minecraft.world.level.ServerTickList saveTickList(Ljava/util/function/Function;Ljava/lang/Iterable;J)Lnet/minecraft/nbt/ListTag; public net.minecraft.world.level.ServerTickList saveTickList(Ljava/util/function/Function;Ljava/lang/Iterable;J)Lnet/minecraft/nbt/ListTag;
public net.minecraft.world.level.chunk.storage.EntityStorage level
# Don't move existing players to world spawn # Don't move existing players to world spawn
public net.minecraft.server.level.ServerPlayer fudgeSpawnLocation(Lnet/minecraft/server/level/ServerLevel;)V public net.minecraft.server.level.ServerPlayer fudgeSpawnLocation(Lnet/minecraft/server/level/ServerLevel;)V

View File

@ -918,7 +918,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ChunkHolder.this.isTickingReady = true; ChunkHolder.this.isTickingReady = true;
+ +
+ // Paper start - rewrite ticklistserver + // Paper start - rewrite ticklistserver
+ ChunkHolder.this.chunkMap.level.onChunkSetTicking(ChunkHolder.this.pos.x, ChunkHolder.this.pos.z); + if (ChunkHolder.this.chunkMap.level.entityManager.areEntitiesLoaded(this.pos.longKey)) {
+ ChunkHolder.this.chunkMap.level.onChunkSetTicking(ChunkHolder.this.pos.x, ChunkHolder.this.pos.z);
+ }
+ // Paper end - rewrite ticklistserver + // Paper end - rewrite ticklistserver
}); });
}); });
@ -932,10 +934,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Paper end // Paper end
+ // Paper start - rewrite ticklistserver + // Paper start - rewrite ticklistserver
+ public final boolean isPositionTickingReady(long pos) {
+ final ChunkHolder chunkHolder = this.chunkMap.getUpdatingChunkIfPresent(pos);
+ return chunkHolder != null && chunkHolder.isTickingReady();
+ }
+
+ public final boolean isPositionTickingWithEntitiesLoaded(BlockPos pos) { + public final boolean isPositionTickingWithEntitiesLoaded(BlockPos pos) {
+ long position = net.minecraft.server.MCUtil.getCoordinateKey(pos); + final long position = net.minecraft.server.MCUtil.getCoordinateKey(pos);
+ ChunkHolder chunkHolder = this.chunkMap.getUpdatingChunkIfPresent(position); + final ChunkHolder chunkHolder = this.chunkMap.getUpdatingChunkIfPresent(position);
+ return chunkHolder != null && chunkHolder.isTickingReady() /* && this.level.entityManager.areEntitiesLoaded(position) */; // TODO Needs to wait for entities, but has to be manually marked as ready + return chunkHolder != null && chunkHolder.isTickingReady() && this.level.entityManager.areEntitiesLoaded(position);
+ } + }
+ // Paper end - rewrite ticklistserver + // Paper end - rewrite ticklistserver
@ -950,7 +957,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end // Paper end
+ // Paper start - rewrite ticklistserver + // Paper start - rewrite ticklistserver
+ void onChunkSetTicking(int chunkX, int chunkZ) { + public void onChunkSetTicking(int chunkX, int chunkZ) {
+ if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) { + if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.blockTicks).onChunkSetTicking(chunkX, chunkZ); + ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.blockTicks).onChunkSetTicking(chunkX, chunkZ);
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.liquidTicks).onChunkSetTicking(chunkX, chunkZ); + ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.liquidTicks).onChunkSetTicking(chunkX, chunkZ);
@ -1111,3 +1118,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@Override @Override
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
this.addEntity(entity, true);
});
this.chunkLoadStatuses.put(chunkEntities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED);
+ // Paper start - rewrite ServerTickList
+ final net.minecraft.server.level.ServerLevel level = ((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level;
+ if (level.chunkSource.isPositionTickingReady(chunkEntities.getPos().longKey)) {
+ level.onChunkSetTicking(chunkEntities.getPos().x, chunkEntities.getPos().z);
+ }
+ // Paper end
}
}