Fix and optimize getChunkCount (#11610)
It was returning ticking chunk count instead of the intended full chunk count. We can also directly use the size of the fullChunks collection instead of iterating all chunks.
This commit is contained in:
@@ -5353,6 +5353,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private NaturalSpawner.SpawnState lastSpawnState;
|
private NaturalSpawner.SpawnState lastSpawnState;
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
+ private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
||||||
|
+ public int getFullChunksCount() {
|
||||||
|
+ return this.fullChunks.size();
|
||||||
|
+ }
|
||||||
+ long chunkFutureAwaitCounter;
|
+ long chunkFutureAwaitCounter;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
|
|||||||
@@ -26281,7 +26281,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final DistanceManager distanceManager;
|
private final DistanceManager distanceManager;
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
}
|
||||||
long chunkFutureAwaitCounter;
|
long chunkFutureAwaitCounter;
|
||||||
// Paper end
|
// Paper end
|
||||||
+ // Paper start - rewrite chunk system
|
+ // Paper start - rewrite chunk system
|
||||||
|
|||||||
@@ -60,15 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public int getChunkCount() {
|
+ public int getChunkCount() {
|
||||||
+ int ret = 0;
|
+ return this.world.getChunkSource().getFullChunksCount();
|
||||||
+
|
|
||||||
+ for (ChunkHolder chunkHolder : ca.spottedleaf.moonrise.common.util.ChunkSystem.getVisibleChunkHolders(this.world)) {
|
|
||||||
+ if (chunkHolder.getTickingChunk() != null) {
|
|
||||||
+ ++ret;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return ret;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
|||||||
Reference in New Issue
Block a user