#include "Chunk.hpp" #include "BlockSide.hpp" namespace MC::World { const Chunk::BlockData& Chunk::at(U32 x, U32 y, U32 z) const { return m_blocks.at(pos(x, y, z)); } Chunk::BlockData& Chunk::at(U32 x, U32 y, U32 z) { return m_blocks.at(pos(x, y, z)); } const Chunk::BlockData& Chunk::at(Position::BlockLocal pos) const { return at(pos.x(), pos.y(), pos.z()); } Chunk::BlockData& Chunk::at(Position::BlockLocal pos) { return at(pos.x(), pos.y(), pos.z()); } ChunkIndex Chunk::index() const { return m_index; } Vector<3> Chunk::position() const { return m_position; } Bool Chunk::is_damaged() const { return m_damaged; } void Chunk::damage() { m_damaged = true; } Bool Chunk::is_valid_position(Position::BlockLocal pos) { return pos.x() < Width && pos.y() < Height && pos.z() < Width; } U64 Chunk::pos(U32 x, U32 y, U32 z) { return x + Width * y + Width * Height * z; } AABB Chunk::block_bounds(Position::BlockLocal pos) { return { {pos.x(), pos.y(), pos.z()}, {pos.x() + 1, pos.y() + 1, pos.z() + 1}, }; } }