Search in sources :

Example 6 with ChunkViewCoreImpl

use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.

the class ChunkViewTest method testOffsetWorldViewAfterMainChunk.

@Test
public void testOffsetWorldViewAfterMainChunk() {
    Chunk chunk = createChunk(0, 0, 0);
    chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
    Chunk[] chunks = new Chunk[] { createChunk(-1, 0, -1), createChunk(0, 0, -1), createChunk(1, 0, -1), createChunk(-1, 0, 0), createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(-1, 0, 1), createChunk(0, 0, 1), chunk };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(0, 0, 0).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(Chunks.SIZE_X, 0, Chunks.SIZE_Z));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) ChunkViewCore(org.terasology.engine.world.internal.ChunkViewCore) Test(org.junit.jupiter.api.Test)

Example 7 with ChunkViewCoreImpl

use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.

the class ChunkViewTest method testOffsetWorldViewBeforeMainChunk.

@Test
public void testOffsetWorldViewBeforeMainChunk() {
    Chunk chunk = createChunk(0, 0, 0);
    chunk.setBlock(new Vector3i(Chunks.SIZE_X - 1, 0, Chunks.SIZE_Z - 1), solidBlock);
    Chunk[] chunks = new Chunk[] { chunk, createChunk(0, 0, -1), createChunk(1, 0, -1), createChunk(-1, 0, 0), createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(-1, 0, 1), createChunk(0, 0, 1), createChunk(1, 0, 1) };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(0, 0, 0).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(-1, 0, -1));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) ChunkViewCore(org.terasology.engine.world.internal.ChunkViewCore) Test(org.junit.jupiter.api.Test)

Example 8 with ChunkViewCoreImpl

use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.

the class ChunkViewTest method testOffsetWorldView.

@Test
public void testOffsetWorldView() {
    Chunk chunk = createChunk(0, 0, 0);
    chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
    Chunk[] chunks = new Chunk[] { createChunk(-1, 0, -1), createChunk(0, 0, -1), createChunk(1, 0, -1), createChunk(-1, 0, 0), chunk, createChunk(1, 0, 0), createChunk(-1, 0, 1), createChunk(0, 0, 1), createChunk(1, 0, 1) };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, new BlockRegion(0, 0, 0).expand(1, 0, 1), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(0, 0, 0));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) ChunkViewCore(org.terasology.engine.world.internal.ChunkViewCore) Test(org.junit.jupiter.api.Test)

Example 9 with ChunkViewCoreImpl

use of org.terasology.engine.world.internal.ChunkViewCoreImpl in project Terasology by MovingBlocks.

the class RemoteChunkProvider method getSubview.

@Override
public ChunkViewCore getSubview(BlockRegionc region, Vector3ic offset) {
    Chunk[] chunks = new Chunk[region.getSizeX() * region.getSizeY() * region.getSizeZ()];
    for (Vector3ic chunkPos : region) {
        Chunk chunk = chunkCache.get(chunkPos);
        int index = (chunkPos.x() - region.minX()) + region.getSizeX() * ((chunkPos.z() - region.minZ()) + region.getSizeZ() * (chunkPos.y() - region.minY()));
        chunks[index] = chunk;
    }
    return new ChunkViewCoreImpl(chunks, region, offset, blockManager.getBlock(BlockManager.AIR_ID));
}
Also used : ChunkViewCoreImpl(org.terasology.engine.world.internal.ChunkViewCoreImpl) Vector3ic(org.joml.Vector3ic) Chunk(org.terasology.engine.world.chunks.Chunk)

Aggregations

ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)9 Chunk (org.terasology.engine.world.chunks.Chunk)8 Vector3i (org.joml.Vector3i)7 BlockRegion (org.terasology.engine.world.block.BlockRegion)7 Test (org.junit.jupiter.api.Test)6 ChunkViewCore (org.terasology.engine.world.internal.ChunkViewCore)5 Vector3ic (org.joml.Vector3ic)3 ChunkMesh (org.terasology.engine.rendering.primitives.ChunkMesh)1 ChunkView (org.terasology.engine.world.ChunkView)1 Block (org.terasology.engine.world.block.Block)1 PreLodChunk (org.terasology.engine.world.chunks.internal.PreLodChunk)1