Search in sources :

Example 6 with ChunkViewCoreImpl

use of org.terasology.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(ChunkConstants.SIZE_X - 1, 0, ChunkConstants.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, Region3i.createFromCenterExtents(new Vector3i(0, 0, 0), new Vector3i(1, 0, 1)), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(-1, 0, -1));
}
Also used : ChunkViewCoreImpl(org.terasology.world.internal.ChunkViewCoreImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) ChunkViewCore(org.terasology.world.internal.ChunkViewCore) Test(org.junit.Test)

Example 7 with ChunkViewCoreImpl

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

the class ChunkViewTest method testOffsetChunksWorldView.

@Test
public void testOffsetChunksWorldView() {
    Chunk chunk = createChunk(1, 0, 1);
    chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
    Chunk[] chunks = new Chunk[] { createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(2, 0, 0), createChunk(0, 0, 1), chunk, createChunk(2, 0, 1), createChunk(0, 0, 2), createChunk(1, 0, 2), createChunk(2, 0, 2) };
    ChunkViewCore chunkView = new ChunkViewCoreImpl(chunks, Region3i.createFromCenterExtents(new Vector3i(1, 0, 1), new Vector3i(1, 0, 1)), new Vector3i(1, 0, 1), airBlock);
    assertEquals(solidBlock, chunkView.getBlock(0, 0, 0));
}
Also used : ChunkViewCoreImpl(org.terasology.world.internal.ChunkViewCoreImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) ChunkViewCore(org.terasology.world.internal.ChunkViewCore) Test(org.junit.Test)

Example 8 with ChunkViewCoreImpl

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

the class ChunkViewTest method testLocalToWorld.

@Test
public void testLocalToWorld() {
    Chunk chunk = createChunk(1, 0, 1);
    chunk.setBlock(new Vector3i(0, 0, 0), solidBlock);
    Chunk[] chunks = new Chunk[] { createChunk(0, 0, 0), createChunk(1, 0, 0), createChunk(2, 0, 0), createChunk(0, 0, 1), chunk, createChunk(2, 0, 1), createChunk(0, 0, 2), createChunk(1, 0, 2), createChunk(2, 0, 2) };
    ChunkViewCoreImpl chunkView = new ChunkViewCoreImpl(chunks, Region3i.createFromCenterExtents(new Vector3i(1, 0, 1), new Vector3i(1, 0, 1)), new Vector3i(1, 1, 1), airBlock);
    assertEquals(new Vector3i(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y, ChunkConstants.SIZE_Z), chunkView.toWorldPos(Vector3i.zero()));
}
Also used : ChunkViewCoreImpl(org.terasology.world.internal.ChunkViewCoreImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) Test(org.junit.Test)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)8 Chunk (org.terasology.world.chunks.Chunk)8 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 Test (org.junit.Test)6 ChunkViewCore (org.terasology.world.internal.ChunkViewCore)5 ManagedChunk (org.terasology.world.chunks.ManagedChunk)1