Search in sources :

Example 1 with IMixinPlayerChunkMap

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);
    }
}
Also used : IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) IMixinChunkProviderServer(org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Chunk(net.minecraft.world.chunk.Chunk) IMixinPlayerChunkMap(org.spongepowered.common.interfaces.server.management.IMixinPlayerChunkMap)

Aggregations

Chunk (net.minecraft.world.chunk.Chunk)1 ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)1 IMixinChunk (org.spongepowered.common.interfaces.IMixinChunk)1 IMixinPlayerChunkMap (org.spongepowered.common.interfaces.server.management.IMixinPlayerChunkMap)1 IMixinChunkProviderServer (org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer)1