docs: Chunks.seekOrigin, Chunks.checkReplaceability

This commit is contained in:
MihailRis 2024-06-10 02:00:41 +03:00
parent 1bfd5ccad3
commit 2dfd2abc40
2 changed files with 16 additions and 2 deletions

View File

@ -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<int>(w) || z >= static_cast<int>(d)) {
return nullptr;
}
return chunks[z * w + x].get();
}

View File

@ -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);
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(