Logo of Mapcraft
Target block

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

  1. MC_PlayerTargetX
    Block X position
  2. MC_PlayerTargetY
    Block Y position
  3. MC_PlayerTargetZ
    Block 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

  1. 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