Search in sources :

Example 11 with Chunk

use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories by Hugobros3.

the class WorldImplementation method peek.

@Override
public /**
 * Fancy get method that throws exceptions when the world isn't loaded
 */
ChunkCell peek(int x, int y, int z) throws WorldException {
    x = sanitizeHorizontalCoordinate(x);
    y = sanitizeVerticalCoordinate(y);
    z = sanitizeHorizontalCoordinate(z);
    Region region = this.getRegionWorldCoordinates(x, y, z);
    if (region == null)
        throw new RegionNotLoadedException(this, x / 256, y / 256, z / 256);
    Chunk chunk = region.getChunk((x / 32) % 8, (y / 32) % 8, (z / 32) % 8);
    if (chunk == null)
        throw new ChunkNotLoadedException(region, (x / 32) % 8, (y / 32) % 8, (z / 32) % 8);
    return chunk.peek(x, y, z);
}
Also used : Region(io.xol.chunkstories.api.world.region.Region) ChunkNotLoadedException(io.xol.chunkstories.api.exceptions.world.ChunkNotLoadedException) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk) RegionNotLoadedException(io.xol.chunkstories.api.exceptions.world.RegionNotLoadedException)

Example 12 with Chunk

use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories by Hugobros3.

the class WorldImplementation method pokeSimple.

@Override
public void pokeSimple(int x, int y, int z, Voxel voxel, int sunlight, int blocklight, int metadata) {
    x = sanitizeHorizontalCoordinate(x);
    y = sanitizeVerticalCoordinate(y);
    z = sanitizeHorizontalCoordinate(z);
    Chunk chunk = this.getChunkWorldCoordinates(x, y, z);
    if (chunk != null)
        chunk.pokeSimple(x, y, z, voxel, sunlight, blocklight, metadata);
}
Also used : Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk)

Example 13 with Chunk

use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories by Hugobros3.

the class WorldImplementation method peekRaw.

@Override
public int peekRaw(int x, int y, int z) {
    x = sanitizeHorizontalCoordinate(x);
    y = sanitizeVerticalCoordinate(y);
    z = sanitizeHorizontalCoordinate(z);
    Chunk chunk = this.getChunkWorldCoordinates(x, y, z);
    if (chunk == null)
        return 0x00000000;
    else
        return chunk.peekRaw(x, y, z);
}
Also used : Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk)

Example 14 with Chunk

use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories by Hugobros3.

the class WorldImplementation method redrawEverything.

@Override
public synchronized // TODO move to client
void redrawEverything() {
    ChunksIterator i = this.getAllLoadedChunks();
    Chunk c;
    while (i.hasNext()) {
        c = i.next();
        if (c instanceof ChunkRenderable) {
            ChunkRenderable c2 = (ChunkRenderable) c;
            c2.lightBaker().requestLightningUpdate();
            c2.meshUpdater().requestMeshUpdate();
        }
    }
}
Also used : ChunkRenderable(io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderable) WorldChunksIterator(io.xol.chunkstories.world.iterators.WorldChunksIterator) ChunksIterator(io.xol.chunkstories.api.world.chunk.ChunksIterator) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk)

Example 15 with Chunk

use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories by Hugobros3.

the class WorldImplementation method pokeSimpleSilently.

@Override
public void pokeSimpleSilently(int x, int y, int z, Voxel voxel, int sunlight, int blocklight, int metadata) {
    x = sanitizeHorizontalCoordinate(x);
    y = sanitizeVerticalCoordinate(y);
    z = sanitizeHorizontalCoordinate(z);
    Chunk chunk = this.getChunkWorldCoordinates(x, y, z);
    if (chunk != null)
        chunk.pokeSimpleSilently(x, y, z, voxel, sunlight, blocklight, metadata);
}
Also used : Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk)

Aggregations

Chunk (io.xol.chunkstories.api.world.chunk.Chunk)22 CubicChunk (io.xol.chunkstories.world.chunk.CubicChunk)12 ChunkRenderable (io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderable)5 Entity (io.xol.chunkstories.api.entity.Entity)3 CellData (io.xol.chunkstories.api.world.cell.CellData)3 Region (io.xol.chunkstories.api.world.region.Region)3 ChunkNotLoadedException (io.xol.chunkstories.api.exceptions.world.ChunkNotLoadedException)2 RegionNotLoadedException (io.xol.chunkstories.api.exceptions.world.RegionNotLoadedException)2 WorldException (io.xol.chunkstories.api.exceptions.world.WorldException)2 Voxel (io.xol.chunkstories.api.voxel.Voxel)2 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)2 FutureCell (io.xol.chunkstories.api.world.cell.FutureCell)2 ChunksIterator (io.xol.chunkstories.api.world.chunk.ChunksIterator)2 ChunkRenderDataHolder (io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder)2 ClientChunk (io.xol.chunkstories.world.chunk.ClientChunk)2 Vector4f (org.joml.Vector4f)2 Location (io.xol.chunkstories.api.Location)1 EntityBase (io.xol.chunkstories.api.entity.EntityBase)1 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)1 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)1