Search in sources :

Example 16 with Chunk

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

the class LocalChunkProviderTest method testCompleteUpdateRestoresEntitiesForRestoredChunks.

@Test
public void testCompleteUpdateRestoresEntitiesForRestoredChunks() throws Exception {
    final Chunk chunk = mockChunkAt(0, 0, 0);
    final ChunkStore chunkStore = mock(ChunkStore.class);
    final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForRestoredChunk(chunk, new TShortObjectHashMap<>(), chunkStore, Collections.emptyList());
    when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
    chunkProvider.completeUpdate();
    verify(chunkStore).restoreEntities();
}
Also used : ReadyChunkInfo(org.terasology.world.chunks.internal.ReadyChunkInfo) Chunk(org.terasology.world.chunks.Chunk) ChunkStore(org.terasology.persistence.ChunkStore) Test(org.junit.Test)

Example 17 with Chunk

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

the class InternalLightGeneratorTest method testBlockedSunlightPropagation.

@Test
public void testBlockedSunlightPropagation() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 4, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
        chunk.setBlock(pos, solidBlock);
    }
    InternalLightProcessor.generateInternalLighting(chunk);
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 5, ChunkConstants.SIZE_Z))) {
        assertEquals("Incorrect lighting at " + pos, 0, chunk.getSunlight(pos));
    }
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) Test(org.junit.Test)

Example 18 with Chunk

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

the class InternalLightGeneratorTest method testBlockedAtTopSunlightRegenPropagationResets.

@Test
public void testBlockedAtTopSunlightRegenPropagationResets() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 63, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
        chunk.setBlock(pos, solidBlock);
    }
    InternalLightProcessor.generateInternalLighting(chunk);
    for (Vector3i pos : Region3i.createFromMinAndSize(Vector3i.zero(), new Vector3i(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y - 1, ChunkConstants.SIZE_Z))) {
        byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 2, ChunkConstants.MAX_SUNLIGHT_REGEN);
        assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
    }
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) Test(org.junit.Test)

Example 19 with Chunk

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

the class InternalLightGeneratorTest method testUnblockedSunlightRegenPropagation.

@Test
public void testUnblockedSunlightRegenPropagation() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
    InternalLightProcessor.generateInternalLighting(chunk);
    for (Vector3i pos : Region3i.createFromMinAndSize(Vector3i.zero(), new Vector3i(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y, ChunkConstants.SIZE_Z))) {
        byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 1, ChunkConstants.MAX_SUNLIGHT_REGEN);
        assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
    }
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) Test(org.junit.Test)

Example 20 with Chunk

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

the class InternalLightGeneratorTest method testUnblockedSunlightPropagation.

@Test
public void testUnblockedSunlightPropagation() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
    InternalLightProcessor.generateInternalLighting(chunk);
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 15, ChunkConstants.SIZE_Z))) {
        assertEquals("Incorrect lighting at " + pos, 15 - pos.y, chunk.getSunlight(pos));
    }
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) Chunk(org.terasology.world.chunks.Chunk) Test(org.junit.Test)

Aggregations

Chunk (org.terasology.world.chunks.Chunk)50 Vector3i (org.terasology.math.geom.Vector3i)31 Test (org.junit.Test)28 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)18 ReadyChunkInfo (org.terasology.world.chunks.internal.ReadyChunkInfo)9 ManagedChunk (org.terasology.world.chunks.ManagedChunk)8 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 ChunkStore (org.terasology.persistence.ChunkStore)7 EntityRef (org.terasology.entitySystem.entity.EntityRef)5 ChunkViewCore (org.terasology.world.internal.ChunkViewCore)5 ChunkProvider (org.terasology.world.chunks.ChunkProvider)3 TIntList (gnu.trove.list.TIntList)2 TShortObjectHashMap (gnu.trove.map.hash.TShortObjectHashMap)2 EntityStore (org.terasology.entitySystem.entity.EntityStore)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 Event (org.terasology.entitySystem.event.Event)2 LocationComponent (org.terasology.logic.location.LocationComponent)2 Side (org.terasology.math.Side)2 StorageManager (org.terasology.persistence.StorageManager)2 Block (org.terasology.world.block.Block)2