1

Execute based on player direction

hogbits's Avatar hogbits10/13/21 12:24 am
1 emeralds 2.9k 5
10/13/2021 1:22 pm
hogbits's Avatar hogbits
Hi All,
I think I need some help understanding the facing command. Basically I need to summon armor stands with a tag based on the direction I am facing.

a long time ago, we used to use /execute @p[rym=136,ry=-135]... if we wanted to detect if the player was facing north

In 1,17 it appears that the new syntax is uses something like /execute as @p facing ~136 ~ ~-135 run say Facing North Obviously this doesn't work. But how do you go about executing based on player direction. In my case I only need to detect North, East, South, West

Thanks in advance
Posted by hogbits's Avatar
hogbits
Level 34 : Artisan Pig
20

Create an account or sign in to comment.

5

hogbits
10/13/2021 1:22 pm
Level 34 : Artisan Pig
hogbits's Avatar
Thanks for the additional examples and explanation. I haven't found the wiki for x_rotation and y_rotation yet. My google-fu must be horrible in my old age. I think your responses should be enough to help me figure out what I need to do.

Basically I am trying to make utility commands to help setup a map with game pieces that require an armor stand to be tagged with a direction. Since there will be more than just a few armor stands to setup, I think a utility that automatically tags the stand when summoned will help quite a bit.

Thank you
1
HoboMaggot
10/13/2021 5:21 am
Level 52 : Grandmaster Blob
history
HoboMaggot's Avatar
/execute as @p facing ~136 ~-135 runs the command as the player, but facing somewhere else
so if you were to do something like spawn a particle or summon an entity, or tp the player to itself, itll do that thinking the player is facing the specific direction when the player is looking elsewhere.

e.g. "execute as @p at @s facing ~136 ~-135 run tp @s ~ ~ ~ ~ ~" will tp the player to the same location but facing those directions.
2
DiversifiedPlayz
10/13/2021 2:14 am
Level 86 : Elite Creator
DiversifiedPlayz's Avatar
/execute if entity @p[y_rotation=-135..-45] run say test
where y_rotation can be -315..-225, -225..-135 or -360..-315 representing the four directions
5
Bittu5134
10/13/2021 12:33 am
Level 82 : Elite Programmer
Bittu5134's Avatar
There is a x_rotation and y_rotation tag for target selector just use them
2
hogbits
10/13/2021 1:57 am
Level 34 : Artisan Pig
history
hogbits's Avatar
Can you give an example? I read about <pos> values on the wiki but it makes no sense the code completion wasnt much help. Or at least I didn't understand it. Google searches reveal results for ray tracing or examples from 4-8 years ago not finding any current results.
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome