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 const Block &GetBlock() const noexcept { return GetChunk().BlockAt(GetBlockPos()); }
26 const BlockType &GetType() const noexcept { return GetChunk().Type(GetBlock()); }
27 int GetLight() const noexcept { return GetChunk().GetLight(GetBlockPos()); }
29 void SetBlock(const Block &b) noexcept { GetChunk().SetBlock(GetBlockPos(), b); }
31 // traverse in given direction
32 BlockLookup Next(Block::Face f) const { return BlockLookup(chunk, pos, f); }