Search in sources :

Example 91 with Vector3i

use of org.terasology.math.geom.Vector3i 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 92 with Vector3i

use of org.terasology.math.geom.Vector3i 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 93 with Vector3i

use of org.terasology.math.geom.Vector3i 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 94 with Vector3i

use of org.terasology.math.geom.Vector3i 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)

Example 95 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class InternalLightGeneratorTest method testBlockedSunlightRegenPropagationResets.

@Test
public void testBlockedSunlightRegenPropagationResets() {
    Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 60, 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, 61, 0), new Vector3i(ChunkConstants.SIZE_X, 3, ChunkConstants.SIZE_Z))) {
        byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 1, ChunkConstants.MAX_SUNLIGHT_REGEN);
        assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
    }
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 60, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
        assertEquals(0, chunk.getSunlightRegen(pos));
    }
    for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 59, ChunkConstants.SIZE_Z))) {
        byte expectedRegen = (byte) Math.min(60 - 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)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)246 Test (org.junit.Test)91 EntityRef (org.terasology.entitySystem.entity.EntityRef)34 Block (org.terasology.world.block.Block)32 Chunk (org.terasology.world.chunks.Chunk)30 Vector3f (org.terasology.math.geom.Vector3f)21 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)17 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)17 Region3i (org.terasology.math.Region3i)15 BaseVector3i (org.terasology.math.geom.BaseVector3i)15 LocationComponent (org.terasology.logic.location.LocationComponent)14 BlockComponent (org.terasology.world.block.BlockComponent)10 Side (org.terasology.math.Side)9 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 Before (org.junit.Before)7 Biome (org.terasology.world.biomes.Biome)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 CoreChunk (org.terasology.world.chunks.CoreChunk)6 RenderableChunk (org.terasology.world.chunks.RenderableChunk)6