Search in sources :

Example 1 with ChunkBlockIterator

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

the class LocalChunkProvider method createBatchBlockEventMappings.

private TShortObjectMap<TIntList> createBatchBlockEventMappings(Chunk chunk) {
    TShortObjectMap<TIntList> batchBlockMap = new TShortObjectHashMap<>();
    blockManager.listRegisteredBlocks().stream().filter(Block::isLifecycleEventsRequired).forEach(block -> batchBlockMap.put(block.getId(), new TIntArrayList()));
    ChunkBlockIterator i = chunk.getBlockIterator();
    while (i.next()) {
        if (i.getBlock().isLifecycleEventsRequired()) {
            TIntList positionList = batchBlockMap.get(i.getBlock().getId());
            positionList.add(i.getBlockPos().x);
            positionList.add(i.getBlockPos().y);
            positionList.add(i.getBlockPos().z);
        }
    }
    return batchBlockMap;
}
Also used : TShortObjectHashMap(gnu.trove.map.hash.TShortObjectHashMap) TIntList(gnu.trove.list.TIntList) TIntArrayList(gnu.trove.list.array.TIntArrayList) ChunkBlockIterator(org.terasology.world.chunks.ChunkBlockIterator)

Aggregations

TIntList (gnu.trove.list.TIntList)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 TShortObjectHashMap (gnu.trove.map.hash.TShortObjectHashMap)1 ChunkBlockIterator (org.terasology.world.chunks.ChunkBlockIterator)1