Search in sources :

Example 1 with AbstractChunkTask

use of org.terasology.world.chunks.pipeline.AbstractChunkTask in project Terasology by MovingBlocks.

the class LocalChunkProvider method createOrLoadChunk.

private void createOrLoadChunk(Vector3i chunkPos) {
    Chunk chunk = chunkCache.get(chunkPos);
    if (chunk == null && !preparingChunks.contains(chunkPos)) {
        preparingChunks.add(chunkPos);
        pipeline.doTask(new AbstractChunkTask(chunkPos) {

            @Override
            public String getName() {
                return "Create or Load Chunk";
            }

            @Override
            public void run() {
                ChunkStore chunkStore = storageManager.loadChunkStore(getPosition());
                Chunk chunk;
                EntityBufferImpl buffer = new EntityBufferImpl();
                if (chunkStore == null) {
                    chunk = new ChunkImpl(getPosition(), blockManager, biomeManager);
                    generator.createChunk(chunk, buffer);
                } else {
                    chunk = chunkStore.getChunk();
                }
                InternalLightProcessor.generateInternalLighting(chunk);
                chunk.deflate();
                TShortObjectMap<TIntList> mappings = createBatchBlockEventMappings(chunk);
                readyChunks.offer(new ReadyChunkInfo(chunk, mappings, chunkStore, buffer.getAll()));
            }
        });
    }
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) AbstractChunkTask(org.terasology.world.chunks.pipeline.AbstractChunkTask) ReadyChunkInfo(org.terasology.world.chunks.internal.ReadyChunkInfo) EntityBufferImpl(org.terasology.world.generation.impl.EntityBufferImpl) TShortObjectMap(gnu.trove.map.TShortObjectMap) Chunk(org.terasology.world.chunks.Chunk) ManagedChunk(org.terasology.world.chunks.ManagedChunk) ChunkStore(org.terasology.persistence.ChunkStore)

Aggregations

TShortObjectMap (gnu.trove.map.TShortObjectMap)1 ChunkStore (org.terasology.persistence.ChunkStore)1 Chunk (org.terasology.world.chunks.Chunk)1 ManagedChunk (org.terasology.world.chunks.ManagedChunk)1 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)1 ReadyChunkInfo (org.terasology.world.chunks.internal.ReadyChunkInfo)1 AbstractChunkTask (org.terasology.world.chunks.pipeline.AbstractChunkTask)1 EntityBufferImpl (org.terasology.world.generation.impl.EntityBufferImpl)1