Search in sources :

Example 1 with RegionNotLoadedException

use of io.xol.chunkstories.api.exceptions.world.RegionNotLoadedException 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 2 with RegionNotLoadedException

use of io.xol.chunkstories.api.exceptions.world.RegionNotLoadedException 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)

Aggregations

ChunkNotLoadedException (io.xol.chunkstories.api.exceptions.world.ChunkNotLoadedException)2 RegionNotLoadedException (io.xol.chunkstories.api.exceptions.world.RegionNotLoadedException)2 Chunk (io.xol.chunkstories.api.world.chunk.Chunk)2 Region (io.xol.chunkstories.api.world.region.Region)2 CubicChunk (io.xol.chunkstories.world.chunk.CubicChunk)2