add :block placement for single blocks

This commit is contained in:
eliotbyte
2025-11-24 21:23:59 +03:00
committed by MihailRis
parent 2af7b23b2e
commit 9ccaecddd2
4 changed files with 153 additions and 7 deletions
@@ -152,6 +152,32 @@ public:
placements.emplace_back(priority, LinePlacement {block, a, b, radius});
}
void perform_block(lua::State* L, std::vector<Placement>& placements) {
rawgeti(L, 2);
blockid_t block = touinteger(L, -1);
pop(L);
rawgeti(L, 3);
glm::ivec3 pos = tovec3(L, -1);
pop(L);
uint8_t rotation = 0;
if (objlen(L, -1) >= 4) {
rawgeti(L, 4);
rotation = tointeger(L, -1) & 0b11;
pop(L);
}
int priority = 0;
if (objlen(L, -1) >= 5) {
rawgeti(L, 5);
priority = tointeger(L, -1);
pop(L);
}
placements.emplace_back(priority, BlockPlacement {block, pos, rotation});
}
void perform_placement(lua::State* L, std::vector<Placement>& placements) {
rawgeti(L, 1);
int structIndex = 0;
@@ -162,6 +188,11 @@ public:
perform_line(L, placements);
return;
} else if (!std::strcmp(name, ":block")) {
pop(L);
perform_block(L, placements);
return;
}
const auto& found = def.structuresIndices.find(name);
if (found != def.structuresIndices.end()) {