use of org.spongepowered.common.interfaces.server.management.IMixinPlayerChunkMap in project SpongeCommon by SpongePowered.
the class MixinWorldServer method doChunkGC.
// Chunk GC
@Override
public void doChunkGC() {
this.chunkGCTickCount++;
ChunkProviderServer chunkProviderServer = this.getChunkProvider();
int chunkLoadCount = this.getChunkProvider().getLoadedChunkCount();
if (chunkLoadCount >= this.chunkGCLoadThreshold && this.chunkGCLoadThreshold > 0) {
chunkLoadCount = 0;
} else if (this.chunkGCTickCount >= this.chunkGCTickInterval && this.chunkGCTickInterval > 0) {
this.chunkGCTickCount = 0;
} else {
return;
}
for (net.minecraft.world.chunk.Chunk chunk : chunkProviderServer.getLoadedChunks()) {
IMixinChunk spongeChunk = (IMixinChunk) chunk;
if (chunk.unloadQueued || spongeChunk.isPersistedChunk() || !this.provider.canDropChunk(chunk.x, chunk.z)) {
continue;
}
// If a player is currently using the chunk, skip it
if (((IMixinPlayerChunkMap) this.getPlayerChunkMap()).isChunkInUse(chunk.x, chunk.z)) {
continue;
}
// If we reach this point the chunk leaked so queue for unload
chunkProviderServer.queueUnload(chunk);
SpongeHooks.logChunkGCQueueUnload(chunkProviderServer.world, chunk);
}
}
Aggregations