#(some_arthena) Determine block face player is breaking

22 messages · Page 1 of 1 (latest)

opal shadow
#

Hey ho!

I am calling the godly devs of this place to aid me on yet another question journey.
What I need is to find the block face the player was looking at after breaking it.

Like, for example: I look at a stone block, but I don't need the direction the player is looking, but the face of the block the player is looking at after they have broken a block.
"Player broke block while looking at the NORTH face of the block.", something along these lines!

Have a good one
Elanda 🙂

Lil' edit:
I would also be absolutely fine just getting the axis of the face, if that is easier, I really just need X, Y or Z, as SOUTH and NORTH for example will be used for the same thing.

trail schoonerBOT
#

(some_arthena) Determine block face player is breaking

trail schoonerBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

opal shadow
#

forgot to mention, the event I am using is on player breaks block, but I figured any event that provides a player and a location will do for the context of this question!

magic karma
#

You can get the normal vector with ray trace

#

!t locationtag.ray_trace

bitter ploverBOT
# magic karma !t locationtag.ray_trace

Traces a line from this location towards the direction it's facing, returning the location of the first hit block or (optionally) entity.
This tag has also been referred to as 'cursor_on' or 'precise_cursor_on' in the past.
For ray tracing entities, see !tag LocationTag.ray_trace_target.
Using 'return=normal' instead replaces the old 'precise_impact_normal' tag.
Optionally specify:
range: (defaults to 200) a maximum distance (in blocks) to trace before giving up.
return: (defaults to prec...

Group

world

Returns

LocationTag

Examples
# Destroys whatever solid block the player is looking at.
- define target <player.eye_location.ray_trace[return=block]||null>
- if <[target]> != null:
    - modifyblock <[target]> air
# Spawns a heart wherever the player is looking, no more than 5 blocks away.
- playeffect effect:heart offset:0 at:<player.eye_location.ray_trace[range=5;entities=*;ignore=<player>;fluids=true;nonsolids=true;default=air]>

and more... Check the website for more examples

magic karma
#

[return=normal]

#

is that what you're looking for?

opal shadow
#

Thanks, I will have a look at it tomorrow
Though it says it will get me the block I am looking at, not the particular face of the block
Let's see 🙂

#

Oh nvm, "normal" vector, let's see

magic karma
#

if you want west/south/east etc you could

#

!t vector_to_face

bitter ploverBOT
# magic karma !t vector_to_face

Returns the name of the BlockFace represented by a normal vector.
Result can be any of the following:
NORTH, EAST, SOUTH, WEST, UP, DOWN, NORTH_EAST, NORTH_WEST, SOUTH_EAST, SOUTH_WEST,
WEST_NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST,
SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST, WEST_SOUTH_WEST, SELF

Returns

ElementTag

magic karma
opal shadow
#

How wonderful, this has absolutely worked wonders!
I thank you from the bottom of my heart.

orchid nymphBOT
#
Resolved

Thread closed as resolved.

opal shadow
#

Little postscript for people who want something similar and don't get the right face:
Make sure you use on player breaks block not after player breaks block, otherwise you get the result of the thing you are looking at after the block was already broken!
And with that I am done, thanks again! 💜

orchid nymphBOT
#
Thread Reopened

Thread was manually reopened by @errant ibex.