Targeted block
Allows to retrieve instantly and regardless of the distance the block targeted by the player
Template
function mapcraft:built_in/targeted_block/main
Parameters
- MC_PlayerTargetXBlock X position
- MC_PlayerTargetYBlock Y position
- MC_PlayerTargetZBlock Z position
In what cases is it useful ?
- You want to know in which direction your player is looking
- You want to know which block the player is looking at
- You want to create a mini game that requires a precise aiming device
Usage
Call the function on a player to update the parameters related to it
All blocks are taken into consideration except those of type air
Example
After execution, the parameters will be equivalent to the value of the first block reached by the aiming
execute as @e[type=minecraft:player] at @s run function mapcraft:built_in/targeted_block/main