fix extended blocks solidity & fix extended blocks neighbours update

This commit is contained in:
MihailRis
2024-10-22 08:06:26 +03:00
parent 64cf9bb273
commit b217c902c4
3 changed files with 39 additions and 2 deletions
+33 -2
View File
@@ -33,6 +33,29 @@ void BlocksController::updateSides(int x, int y, int z) {
updateBlock(x, y, z + 1);
}
void BlocksController::updateSides(int x, int y, int z, int w, int h, int d) {
voxel* vox = chunks->get(x, y, z);
const auto& def = level->content->getIndices()->blocks.require(vox->id);
const auto& rot = def.rotations.variants[vox->state.rotation];
const auto& xaxis = rot.axisX;
const auto& yaxis = rot.axisY;
const auto& zaxis = rot.axisZ;
for (int ly = -1; ly <= h; ly++) {
for (int lz = -1; lz <= d; lz++) {
for (int lx = -1; lx <= w; lx++) {
if (lx >= 0 && lx < w && ly >= 0 && ly < h && lz >= 0 && lz < d) {
continue;
}
updateBlock(
x + lx * xaxis.x + ly * yaxis.x + lz * zaxis.x,
y + lx * xaxis.y + ly * yaxis.y + lz * zaxis.y,
z + lx * xaxis.z + ly * yaxis.z + lz * zaxis.z
);
}
}
}
}
void BlocksController::breakBlock(
Player* player, const Block& def, int x, int y, int z
) {
@@ -42,7 +65,11 @@ void BlocksController::breakBlock(
chunks->set(x, y, z, 0, {});
lighting->onBlockSet(x, y, z, 0);
scripting::on_block_broken(player, def, x, y, z);
updateSides(x, y, z);
if (def.rt.extended) {
updateSides(x, y, z , def.size.x, def.size.y, def.size.z);
} else {
updateSides(x, y, z);
}
}
void BlocksController::placeBlock(
@@ -56,7 +83,11 @@ void BlocksController::placeBlock(
if (def.rt.funcsset.onplaced) {
scripting::on_block_placed(player, def, x, y, z);
}
updateSides(x, y, z);
if (def.rt.extended) {
updateSides(x, y, z , def.size.x, def.size.y, def.size.z);
} else {
updateSides(x, y, z);
}
}
void BlocksController::updateBlock(int x, int y, int z) {