Package org.terasology.world.chunks

Examples of org.terasology.world.chunks.CoreChunk


    }

    @Override
    public Block setBlock(Vector3i worldPos, Block type) {
        Vector3i chunkPos = TeraMath.calcChunkPos(worldPos);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(worldPos);
            chunk.lock();
            Block oldBlockType = chunk.setBlock(blockPos, type);
            chunk.unlock();
            if (oldBlockType != type) {
                BlockChange oldChange = blockChanges.get(worldPos);
                if (oldChange == null) {
                    blockChanges.put(worldPos, new BlockChange(worldPos, oldBlockType, type));
                } else {
View Full Code Here


    }

    @Override
    public boolean setLiquid(int x, int y, int z, LiquidData newState, LiquidData oldState) {
        Vector3i chunkPos = TeraMath.calcChunkPos(x, y, z);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            chunk.lock();
            try {
                Vector3i blockPos = TeraMath.calcBlockPos(x, y, z);
                LiquidData liquidState = chunk.getLiquid(blockPos);
                if (liquidState.equals(oldState)) {
                    chunk.setLiquid(blockPos, newState);
                    return true;
                }
            } finally {
                chunk.unlock();
            }
        }
        return false;
    }
View Full Code Here

    }

    @Override
    public LiquidData getLiquid(int x, int y, int z) {
        Vector3i chunkPos = TeraMath.calcChunkPos(x, y, z);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(x, y, z);
            return chunk.getLiquid(blockPos);
        }
        logger.warn("Attempted to access unavailable chunk via liquid data at {}, {}, {}", x, y, z);
        return new LiquidData();
    }
View Full Code Here

    }

    @Override
    public Block getBlock(int x, int y, int z) {
        Vector3i chunkPos = TeraMath.calcChunkPos(x, y, z);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(x, y, z);
            return chunk.getBlock(blockPos);
        }
        logger.warn("Attempted to access unavailable chunk via block at {}, {}, {}", x, y, z);
        return BlockManager.getAir();
    }
View Full Code Here

    }

    @Override
    public Biome getBiome(Vector3i pos) {
        Vector3i chunkPos = TeraMath.calcChunkPos(pos);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(pos);
            return chunk.getBiome(blockPos.x, blockPos.y, blockPos.z);
        }
        logger.warn("Attempted to access unavailable chunk via block at {}, {}, {}", pos.x, pos.y, pos.z);
        return BiomeManager.getUnknownBiome();
    }
View Full Code Here

    }

    @Override
    public Biome setBiome(Vector3i worldPos, Biome biome) {
        Vector3i chunkPos = TeraMath.calcChunkPos(worldPos);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(worldPos);
            chunk.lock();
            Biome oldBiomeType = chunk.setBiome(blockPos.x, blockPos.y, blockPos.z, biome);
            chunk.unlock();
            if (oldBiomeType != biome) {
                BiomeChange oldChange = biomeChanges.get(worldPos);
                if (oldChange == null) {
                    biomeChanges.put(worldPos, new BiomeChange(worldPos, oldBiomeType, biome));
                } else {
View Full Code Here

     */
    protected abstract void setValueAt(LitChunk chunk, Vector3i pos, byte value);

    @Override
    public Block getBlockAt(Vector3i pos) {
        CoreChunk chunk = chunkProvider.getChunk(TeraMath.calcChunkPos(pos));
        if (chunk != null) {
            return chunk.getBlock(TeraMath.calcBlockPos(pos));
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.terasology.world.chunks.CoreChunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.