add 'grounded' support for 'pipe' rotation profile
This commit is contained in:
parent
359123bb36
commit
4c8ae465c7
@ -13,5 +13,6 @@
|
|||||||
"light-passing": true,
|
"light-passing": true,
|
||||||
"shadeless": true,
|
"shadeless": true,
|
||||||
"obstacle": false,
|
"obstacle": false,
|
||||||
|
"grounded": true,
|
||||||
"rotation": "pipe"
|
"rotation": "pipe"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,10 +84,13 @@ void BlocksController::updateBlock(int x, int y, int z) {
|
|||||||
if (vox == nullptr)
|
if (vox == nullptr)
|
||||||
return;
|
return;
|
||||||
const Block* def = level->content->getIndices()->getBlockDef(vox->id);
|
const Block* def = level->content->getIndices()->getBlockDef(vox->id);
|
||||||
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
|
if (def->grounded) {
|
||||||
|
const auto& vec = get_ground_direction(def, vox->state.rotation);
|
||||||
|
if (!chunks->isSolidBlock(x+vec.x, y+vec.y, z+vec.z)) {
|
||||||
breakBlock(nullptr, def, x, y, z);
|
breakBlock(nullptr, def, x, y, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (def->rt.funcsset.update) {
|
if (def->rt.funcsset.update) {
|
||||||
scripting::update_block(def, x, y, z);
|
scripting::update_block(def, x, y, z);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -404,9 +404,12 @@ void PlayerController::processRightClick(Block* def, Block* target) {
|
|||||||
if (!chunks->checkReplaceability(def, state, coord)) {
|
if (!chunks->checkReplaceability(def, state, coord)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (def->grounded && !chunks->isSolidBlock(coord.x, coord.y-1, coord.z)) {
|
if (def->grounded) {
|
||||||
|
const auto& vec = get_ground_direction(def, state.rotation);
|
||||||
|
if (!chunks->isSolidBlock(coord.x+vec.x, coord.y+vec.y, coord.z+vec.z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (chosenBlock != vox->id && chosenBlock) {
|
if (chosenBlock != vox->id && chosenBlock) {
|
||||||
onBlockInteraction(coord, def, BlockInteraction::placing);
|
onBlockInteraction(coord, def, BlockInteraction::placing);
|
||||||
chunks->set(coord.x, coord.y, coord.z, chosenBlock, state);
|
chunks->set(coord.x, coord.y, coord.z, chosenBlock, state);
|
||||||
|
|||||||
@ -202,4 +202,13 @@ public:
|
|||||||
Block(const Block&) = delete;
|
Block(const Block&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline glm::ivec3 get_ground_direction(const Block* def, int rotation) {
|
||||||
|
const auto& profileName = def->rotations.name;
|
||||||
|
if (profileName == BlockRotProfile::PIPE_NAME) {
|
||||||
|
return -def->rotations.variants[rotation].axisY;
|
||||||
|
} else {
|
||||||
|
return glm::ivec3(0, -1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VOXELS_BLOCK_HPP_
|
#endif // VOXELS_BLOCK_HPP_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user