fix: on_block_placed not calling

This commit is contained in:
MihailRis 2024-10-23 12:10:02 +03:00
parent 5dce372156
commit 3b5857ee62
2 changed files with 9 additions and 9 deletions

View File

@ -80,9 +80,7 @@ void BlocksController::placeBlock(
); );
chunks->set(x, y, z, def.rt.id, state); chunks->set(x, y, z, def.rt.id, state);
lighting->onBlockSet(x, y, z, def.rt.id); lighting->onBlockSet(x, y, z, def.rt.id);
if (def.rt.funcsset.onplaced) { scripting::on_block_placed(player, def, x, y, z);
scripting::on_block_placed(player, def, x, y, z);
}
if (def.rt.extended) { if (def.rt.extended) {
updateSides(x, y, z , def.size.x, def.size.y, def.size.z); updateSides(x, y, z , def.size.x, def.size.y, def.size.z);
} else { } else {

View File

@ -230,12 +230,14 @@ void scripting::random_update_block(const Block& block, int x, int y, int z) {
void scripting::on_block_placed( void scripting::on_block_placed(
Player* player, const Block& block, int x, int y, int z Player* player, const Block& block, int x, int y, int z
) { ) {
std::string name = block.name + ".placed"; if (block.rt.funcsset.onplaced) {
lua::emit_event(lua::get_main_state(), name, [x, y, z, player](auto L) { std::string name = block.name + ".placed";
lua::pushivec_stack(L, glm::ivec3(x, y, z)); lua::emit_event(lua::get_main_state(), name, [x, y, z, player](auto L) {
lua::pushinteger(L, player ? player->getId() : -1); lua::pushivec_stack(L, glm::ivec3(x, y, z));
return 4; lua::pushinteger(L, player ? player->getId() : -1);
}); return 4;
});
}
auto world_event_args = [&](lua::State* L) { auto world_event_args = [&](lua::State* L) {
lua::pushinteger(L, block.rt.id); lua::pushinteger(L, block.rt.id);
lua::pushivec_stack(L, glm::ivec3(x, y, z)); lua::pushivec_stack(L, glm::ivec3(x, y, z));