Search in sources :

Example 1 with TShortObjectMap

use of gnu.trove.map.TShortObjectMap 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)

Example 2 with TShortObjectMap

use of gnu.trove.map.TShortObjectMap in project Terasology by MovingBlocks.

the class LocalChunkProvider method deactivateBlocks.

private void deactivateBlocks() {
    List<TShortObjectMap<TIntList>> deactivatedBlockSets = Lists.newArrayListWithExpectedSize(deactivateBlocksQueue.size());
    deactivateBlocksQueue.drainTo(deactivatedBlockSets);
    for (TShortObjectMap<TIntList> deactivatedBlockSet : deactivatedBlockSets) {
        deactivatedBlockSet.forEachEntry((id, positions) -> {
            if (positions.size() > 0) {
                blockManager.getBlock(id).getEntity().send(new BeforeDeactivateBlocks(positions, registry));
            }
            return true;
        });
    }
}
Also used : TShortObjectMap(gnu.trove.map.TShortObjectMap) TIntList(gnu.trove.list.TIntList) BeforeDeactivateBlocks(org.terasology.world.block.BeforeDeactivateBlocks)

Example 3 with TShortObjectMap

use of gnu.trove.map.TShortObjectMap in project Terasology by MovingBlocks.

the class LocalChunkProvider method deactivateBlocks.

private void deactivateBlocks() {
    List<TShortObjectMap<TIntList>> deactivatedBlockSets = Lists.newArrayListWithExpectedSize(deactivateBlocksQueue.size());
    deactivateBlocksQueue.drainTo(deactivatedBlockSets);
    for (TShortObjectMap<TIntList> deactivatedBlockSet : deactivatedBlockSets) {
        deactivatedBlockSet.forEachEntry((id, positions) -> {
            if (positions.size() > 0) {
                blockManager.getBlock(id).getEntity().send(new BeforeDeactivateBlocks(positions, registry));
            }
            return true;
        });
    }
}
Also used : TShortObjectMap(gnu.trove.map.TShortObjectMap) TIntList(gnu.trove.list.TIntList) BeforeDeactivateBlocks(org.terasology.engine.world.block.BeforeDeactivateBlocks)

Aggregations

TShortObjectMap (gnu.trove.map.TShortObjectMap)3 TIntList (gnu.trove.list.TIntList)2 BeforeDeactivateBlocks (org.terasology.engine.world.block.BeforeDeactivateBlocks)1 ChunkStore (org.terasology.persistence.ChunkStore)1 BeforeDeactivateBlocks (org.terasology.world.block.BeforeDeactivateBlocks)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