Search in sources :

Example 16 with Chunk

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

the class WorldImplementation method poke.

@Override
public ChunkCell poke(int x, int y, int z, Voxel voxel, int sunlight, int blocklight, int metadata, WorldModificationCause cause) 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.poke(x, y, z, voxel, sunlight, blocklight, metadata, cause);
}
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 17 with Chunk

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

the class WorldImplementation method pokeRaw.

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

Example 18 with Chunk

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

the class WorldImplementation method peekSafely.

@Override
public WorldCell peekSafely(int x, int y, int z) {
    x = sanitizeHorizontalCoordinate(x);
    y = sanitizeVerticalCoordinate(y);
    z = sanitizeHorizontalCoordinate(z);
    Region region = this.getRegionWorldCoordinates(x, y, z);
    if (region == null) {
        return new UnloadedWorldCell(x, y, z, this.getGameContext().getContent().voxels().air(), 0, 0, 0);
    }
    Chunk chunk = region.getChunk((x / 32) % 8, (y / 32) % 8, (z / 32) % 8);
    if (chunk == null)
        return new UnloadedWorldCell(x, y, z, this.getGameContext().getContent().voxels().air(), 0, 0, 0);
    return chunk.peek(x, y, z);
}
Also used : Region(io.xol.chunkstories.api.world.region.Region) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CubicChunk(io.xol.chunkstories.world.chunk.CubicChunk)

Example 19 with Chunk

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

the class WorldImplementation method pokeRawSilently.

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

Example 20 with Chunk

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

the class ChunkLightBaker method pokeRawFast.

private void pokeRawFast(int x, int y, int z, int data) {
    // Still within bounds !
    CubicChunk relevantChunk = findRelevantChunk(x, y, z);
    if (relevantChunk != null) {
        chunk.pokeRawSilently(x, y, z, data);
        return;
    }
    int oldData = world.peekRaw(x + chunkX * 32, y + chunkY * 32, z + chunkZ * 32);
    world.pokeRawSilently(x + chunkX * 32, y + chunkY * 32, z + chunkZ * 32, data);
    Chunk updateme = world.getChunkWorldCoordinates(x + chunkX * 32, y + chunkY * 32, z + chunkZ * 32);
    if (updateme != null && oldData != data)
        updateme.lightBaker().requestLightningUpdate();
}
Also used : Chunk(io.xol.chunkstories.api.world.chunk.Chunk)

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