1

Is it possible to get the position of player's targeted block?

Guris's Avatar Guris6/30/23 10:58 am
1 emeralds 229 1
6/30/2023 11:56 am
Guris's Avatar Guris
I'm designing a data pack that requires detecting the player's targeted block while holding a specific item in the primary hand. At first, I thought it would be easy if there's an NBT tag for the player entity, but I cannot find it anywhere. Raycasting can be one way of doing it, but I want the exact block the player can touch, not just look at, i.d., the player can break (left) or interact (right) with the block right now. Is there any simple way of doing it? I will be grateful if anyone provides a tutorial or an example data pack I can learn with.
Posted by Guris's Avatar
Guris
Level 26 : Expert Engineer
5

Create an account or sign in to comment.

1

Guris
06/30/2023 11:56 am
Level 26 : Expert Engineer
Guris's Avatar
I think I just figured it out. Is this right?
execute as @p anchored eyes positioned ^ ^ ^ run ...
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome