]> git.localhorst.tv Git - blank.git/blobdiff - src/world/BlockLookup.hpp
group entity updates in as few packets as possible
[blank.git] / src / world / BlockLookup.hpp
index 4c8b12ba41a6a50f14c4f5033b685ce42ddaeca3..e861b249efd628b8c4dc83b74ef792e2fab97cd3 100644 (file)
@@ -10,22 +10,25 @@ namespace blank {
 class BlockLookup {
 
 public:
-       // resolve chunk/position from oob coordinates
+       /// resolve chunk/position from oob coordinates
        BlockLookup(Chunk *c, const Chunk::Pos &p) noexcept;
 
-       // resolve chunk/position from ib coordinates and direction
+       /// resolve chunk/position from ib coordinates and direction
        BlockLookup(Chunk *c, const Chunk::Pos &p, Block::Face dir) noexcept;
 
-       // check if lookup was successful
+       /// check if lookup was successful
        operator bool() const { return chunk; }
 
        // only valid if lookup was successful
        Chunk &GetChunk() const noexcept { return *chunk; }
        const Chunk::Pos &GetBlockPos() const noexcept { return pos; }
+       Block::Pos GetBlockCoords() const noexcept { return Chunk::ToCoords(pos); }
        const Block &GetBlock() const noexcept { return GetChunk().BlockAt(GetBlockPos()); }
        const BlockType &GetType() const noexcept { return GetChunk().Type(GetBlock()); }
        int GetLight() const noexcept { return GetChunk().GetLight(GetBlockPos()); }
 
+       void SetBlock(const Block &b) noexcept { GetChunk().SetBlock(GetBlockPos(), b); }
+
        // traverse in given direction
        BlockLookup Next(Block::Face f) const { return BlockLookup(chunk, pos, f); }