mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
add can_be_placed block event
can_be_placed(x, y, z, playerid, rotation) is called before a player places the block, after the built-in checks (replaceability, grounded, entities). The block is placed only if the function returns true. rotation is the rotation the block is going to be placed with, so blocks like ladders can check the block they are attached to. The event is not called for block.place / block.set. Closes #909
This commit is contained in:
parent
1dd1af1a72
commit
2a01cfc5b1
6 changed files with 68 additions and 0 deletions
|
|
@ -480,6 +480,11 @@ void PlayerController::processRightClick(
|
|||
}
|
||||
}
|
||||
if (chosenBlock != vox->id && chosenBlock) {
|
||||
if (!scripting::can_block_be_placed(
|
||||
&player, def, coord, state.rotation
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
if (!player.isInfiniteItems()) {
|
||||
auto& slot = player.getInventory()->getSlot(player.getChosenSlot());
|
||||
slot.setCount(slot.getCount() - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue