add on_replaced block event and on_block_replaced world event

This commit is contained in:
MihailRis
2024-11-22 12:31:45 +03:00
parent b40c8c4b4c
commit f2e7a54180
7 changed files with 54 additions and 0 deletions
+7
View File
@@ -75,6 +75,13 @@ void BlocksController::breakBlock(
void BlocksController::placeBlock(
Player* player, const Block& def, blockstate state, int x, int y, int z
) {
auto voxel = chunks.get(x, y, z);
if (voxel == nullptr) {
return;
}
const auto& prevDef = level.content->getIndices()->blocks.require(voxel->id);
scripting::on_block_replaced(player, prevDef, {x, y, z});
onBlockInteraction(
player, glm::ivec3(x, y, z), def, BlockInteraction::placing
);