Search in sources :

Example 66 with Chunk

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

the class WorldProviderCoreImpl method getLight.

@Override
public byte getLight(int x, int y, int z) {
    Vector3i chunkPos = Chunks.toChunkPos(x, y, z, new Vector3i());
    Chunk chunk = chunkProvider.getChunk(chunkPos);
    if (chunk != null) {
        Vector3i blockPos = Chunks.toRelative(x, y, z, new Vector3i());
        return chunk.getLight(blockPos);
    }
    return 0;
}
Also used : Vector3i(org.joml.Vector3i) Chunk(org.terasology.engine.world.chunks.Chunk)

Example 67 with Chunk

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

the class LocalChunkView method getBlockAt.

@Override
public Block getBlockAt(Vector3ic pos) {
    int index = chunkIndexOf(pos);
    Chunk chunk = chunks[index];
    if (chunk != null) {
        return chunk.getBlock(Chunks.toRelative(pos, new Vector3i()));
    }
    return null;
}
Also used : Vector3i(org.joml.Vector3i) Chunk(org.terasology.engine.world.chunks.Chunk)

Aggregations

Chunk (org.terasology.engine.world.chunks.Chunk)67 Vector3i (org.joml.Vector3i)36 Vector3ic (org.joml.Vector3ic)33 Test (org.junit.jupiter.api.Test)29 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)25 BlockRegion (org.terasology.engine.world.block.BlockRegion)24 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)8 Map (java.util.Map)7 RenderableChunk (org.terasology.engine.world.chunks.RenderableChunk)7 Lists (com.google.common.collect.Lists)6 Maps (com.google.common.collect.Maps)6 Comparator (java.util.Comparator)6 List (java.util.List)6 ExecutionException (java.util.concurrent.ExecutionException)6 Future (java.util.concurrent.Future)6 TimeUnit (java.util.concurrent.TimeUnit)6 TimeoutException (java.util.concurrent.TimeoutException)6 Assertions (org.junit.jupiter.api.Assertions)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 BlockManager (org.terasology.engine.world.block.BlockManager)6