@Override public byte getValueAt(Vector3i pos) { LitChunk chunk = getChunk(pos); if (chunk != null) { return getValueAt(chunk, ChunkMath.calcBlockPos(pos.x, pos.y, pos.z)); } return UNAVAILABLE; }
@Override public void setValueAt(Vector3i pos, byte value) { Chunk chunk = chunks[chunkIndexOf(pos)]; if (chunk != null) { rules.setValue(chunk, ChunkMath.calcBlockPos(pos), value); } }
@Override public Block getBlockAt(Vector3i pos) { int index = chunkIndexOf(pos); Chunk chunk = chunks[index]; if (chunk != null) { return chunk.getBlock(ChunkMath.calcBlockPos(pos)); } return null; } }
@Override public byte getValueAt(Vector3i pos) { Chunk chunk = chunks[chunkIndexOf(pos)]; if (chunk != null) { return rules.getValue(chunk, ChunkMath.calcBlockPos(pos)); } return UNAVAILABLE; }
@Override public void setBlock(int blockX, int blockY, int blockZ, Block type) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { int chunkIndex = relChunkIndex(blockX, blockY, blockZ); chunks[chunkIndex].setBlock(ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize), type); } else { logger.warn("Attempt to modify block outside of the view"); } }
@Override public void setBiome(int blockX, int blockY, int blockZ, Biome biome) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { int chunkIndex = relChunkIndex(blockX, blockY, blockZ); Vector3i pos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize); chunks[chunkIndex].setBiome(pos.x, pos.y, pos.z, biome); } else { logger.warn("Attempt to modify biome outside of the view"); } }
@Override public void setLight(int blockX, int blockY, int blockZ, byte light) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { int chunkIndex = relChunkIndex(blockX, blockY, blockZ); chunks[chunkIndex].setLight(ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize), light); } else { logger.warn("Attempted to set light at a position not encompassed by the view"); } }
@Override public void setSunlight(int blockX, int blockY, int blockZ, byte light) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { int chunkIndex = relChunkIndex(blockX, blockY, blockZ); chunks[chunkIndex].setSunlight(ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize), light); } else { throw new IllegalStateException("Attempted to modify sunlight though an unlocked view"); } }
@Override public void setExtraData(int index, int blockX, int blockY, int blockZ, int value) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { int chunkIndex = relChunkIndex(blockX, blockY, blockZ); chunks[chunkIndex].setExtraData(index, ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize), value); } else { throw new IllegalStateException("Attempted to modify extra data though an unlocked view"); } }
@Override public byte getTotalLight(int x, int y, int z) { Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z); LitChunk chunk = chunkProvider.getChunk(chunkPos); if (chunk != null) { Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z); return (byte) Math.max(chunk.getSunlight(blockPos), chunk.getLight(blockPos)); } return 0; }
@Override public byte getLight(int x, int y, int z) { Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z); LitChunk chunk = chunkProvider.getChunk(chunkPos); if (chunk != null) { Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z); return chunk.getLight(blockPos); } return 0; }
@Override public byte getSunlight(int blockX, int blockY, int blockZ) { if (!blockRegion.encompasses(blockX, blockY, blockZ)) { return 0; } int chunkIndex = relChunkIndex(blockX, blockY, blockZ); return chunks[chunkIndex].getSunlight(ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize)); }
@Override public Block getBlockAt(Vector3i pos) { CoreChunk chunk = chunkProvider.getChunk(ChunkMath.calcChunkPos(pos)); if (chunk != null) { return chunk.getBlock(ChunkMath.calcBlockPos(pos)); } return null; }
@Override public int getExtraData(int index, int blockX, int blockY, int blockZ) { if (!blockRegion.encompasses(blockX, blockY, blockZ)) { return 0; } int chunkIndex = relChunkIndex(blockX, blockY, blockZ); return chunks[chunkIndex].getExtraData(index, ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize)); }
@Override public byte getSunlight(int x, int y, int z) { Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z); LitChunk chunk = chunkProvider.getChunk(chunkPos); if (chunk != null) { Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z); return chunk.getSunlight(blockPos); } return 0; }
@Override public byte getLight(int blockX, int blockY, int blockZ) { if (!blockRegion.encompasses(blockX, blockY, blockZ)) { return 0; } int chunkIndex = relChunkIndex(blockX, blockY, blockZ); return chunks[chunkIndex].getLight(ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize)); }
@Override public Biome getBiome(Vector3i pos) { Vector3i chunkPos = ChunkMath.calcChunkPos(pos); CoreChunk chunk = chunkProvider.getChunk(chunkPos); if (chunk != null) { Vector3i blockPos = ChunkMath.calcBlockPos(pos); return chunk.getBiome(blockPos.x, blockPos.y, blockPos.z); } return BiomeManager.getUnknownBiome(); }
@Override public Biome getBiome(int blockX, int blockY, int blockZ) { if (!blockRegion.encompasses(blockX, blockY, blockZ)) { return BiomeManager.getUnknownBiome(); } int chunkIndex = relChunkIndex(blockX, blockY, blockZ); Vector3i blockPos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize); return chunks[chunkIndex].getBiome(blockPos.x, blockPos.y, blockPos.z); }
@Override public void setValueAt(Vector3i pos, byte value) { setValueAt(getChunk(pos), ChunkMath.calcBlockPos(pos.x, pos.y, pos.z), value); for (Vector3i affectedChunkPos : ChunkMath.getChunkRegionAroundWorldPos(pos, 1)) { Chunk dirtiedChunk = chunkProvider.getChunk(affectedChunkPos); if (dirtiedChunk != null) { dirtiedChunk.setDirty(true); } } }
static Region3i getChunkRegionAbove(Vector3f location) { Vector3i charecterPos = new Vector3i(location); Vector3i chunkAboveCharacter = ChunkMath.calcChunkPos(charecterPos); chunkAboveCharacter.addY(1); Vector3i chunkRelativePos = ChunkMath.calcBlockPos(charecterPos); Vector3i characterChunkOriginPos = new Vector3i(charecterPos); characterChunkOriginPos.sub(chunkRelativePos); Vector3i chunkAboveOrigin = new Vector3i(characterChunkOriginPos); chunkAboveOrigin.addY(ChunkConstants.CHUNK_SIZE.getY()); return ChunkConstants.CHUNK_REGION.move(chunkAboveOrigin); }