From 3b5857ee624e4176f3294ae825d9888d6f016b87 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 23 Oct 2024 12:10:02 +0300 Subject: [PATCH] fix: on_block_placed not calling --- src/logic/BlocksController.cpp | 4 +--- src/logic/scripting/scripting.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/logic/BlocksController.cpp b/src/logic/BlocksController.cpp index 45095fcb..cad8ae70 100644 --- a/src/logic/BlocksController.cpp +++ b/src/logic/BlocksController.cpp @@ -80,9 +80,7 @@ void BlocksController::placeBlock( ); chunks->set(x, y, z, def.rt.id, state); 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) { updateSides(x, y, z , def.size.x, def.size.y, def.size.z); } else { diff --git a/src/logic/scripting/scripting.cpp b/src/logic/scripting/scripting.cpp index 42120534..8456e220 100644 --- a/src/logic/scripting/scripting.cpp +++ b/src/logic/scripting/scripting.cpp @@ -230,12 +230,14 @@ void scripting::random_update_block(const Block& block, int x, int y, int z) { void scripting::on_block_placed( Player* player, const Block& block, int x, int y, int z ) { - std::string name = block.name + ".placed"; - lua::emit_event(lua::get_main_state(), name, [x, y, z, player](auto L) { - lua::pushivec_stack(L, glm::ivec3(x, y, z)); - lua::pushinteger(L, player ? player->getId() : -1); - return 4; - }); + if (block.rt.funcsset.onplaced) { + std::string name = block.name + ".placed"; + lua::emit_event(lua::get_main_state(), name, [x, y, z, player](auto L) { + lua::pushivec_stack(L, glm::ivec3(x, y, z)); + lua::pushinteger(L, player ? player->getId() : -1); + return 4; + }); + } auto world_event_args = [&](lua::State* L) { lua::pushinteger(L, block.rt.id); lua::pushivec_stack(L, glm::ivec3(x, y, z));