1 #ifndef BLANK_WORLD_BLOCKLOOKUP_HPP_
2 #define BLANK_WORLD_BLOCKLOOKUP_HPP_
13 /// resolve chunk/position from oob coordinates
14 BlockLookup(Chunk *c, const Chunk::Pos &p) noexcept;
16 /// resolve chunk/position from ib coordinates and direction
17 BlockLookup(Chunk *c, const Chunk::Pos &p, Block::Face dir) noexcept;
19 /// check if lookup was successful
20 operator bool() const { return chunk; }
22 // only valid if lookup was successful
23 Chunk &GetChunk() const noexcept { return *chunk; }
24 const Chunk::Pos &GetBlockPos() const noexcept { return pos; }
25 Block::Pos GetBlockCoords() const noexcept { return Chunk::ToCoords(pos); }
26 const Block &GetBlock() const noexcept { return GetChunk().BlockAt(GetBlockPos()); }
27 const BlockType &GetType() const noexcept { return GetChunk().Type(GetBlock()); }
28 int GetLight() const noexcept { return GetChunk().GetLight(GetBlockPos()); }
30 void SetBlock(const Block &b) noexcept { GetChunk().SetBlock(GetBlockPos(), b); }
32 // traverse in given direction
33 BlockLookup Next(Block::Face f) const { return BlockLookup(chunk, pos, f); }