diff --git a/src/voxels/Chunks.cpp b/src/voxels/Chunks.cpp index 61c70058..413cab85 100644 --- a/src/voxels/Chunks.cpp +++ b/src/voxels/Chunks.cpp @@ -158,8 +158,9 @@ Chunk* Chunks::getChunkByVoxel(int32_t x, int32_t y, int32_t z) { Chunk* Chunks::getChunk(int x, int z){ x -= ox; z -= oz; - if (x < 0 || z < 0 || x >= int(w) || z >= int(d)) + if (x < 0 || z < 0 || x >= static_cast(w) || z >= static_cast(d)) { return nullptr; + } return chunks[z * w + x].get(); } diff --git a/src/voxels/Chunks.hpp b/src/voxels/Chunks.hpp index 54b20b29..fb8185d4 100644 --- a/src/voxels/Chunks.hpp +++ b/src/voxels/Chunks.hpp @@ -41,7 +41,6 @@ public: WorldFiles* worldFiles, LevelEvents* events, const Content* content); ~Chunks() = default; - bool checkReplaceability(const Block* def, blockstate state, glm::ivec3 coord, blockid_t ignore=0); bool putChunk(const std::shared_ptr& chunk); Chunk* getChunk(int32_t x, int32_t z); @@ -55,7 +54,21 @@ public: light_t getLight(int32_t x, int32_t y, int32_t z); ubyte getLight(int32_t x, int32_t y, int32_t z, int channel); void set(int32_t x, int32_t y, int32_t z, uint32_t id, blockstate state); + + /// @brief Seek for the extended block origin position + /// @param pos segment block position + /// @param def segment block definition + /// @param state segment block state + /// @return origin block position or `pos` if block is not extended glm::ivec3 seekOrigin(glm::ivec3 pos, const Block* def, blockstate state); + + /// @brief Check if required zone is replaceable + /// @param def definition of the block that requires a replaceable zone + /// @param state the block state + /// @param coord position of the zone start + /// @param ignore ignored block id (will be counted as replaceable) + bool checkReplaceability(const Block* def, blockstate state, glm::ivec3 coord, blockid_t ignore=0); + void setRotation(int32_t x, int32_t y, int32_t z, uint8_t rotation); voxel* rayCast(