Minecraft Command help: testfor/execute questions [closed]
Im using command block on a multiplayer map I am creating. Is there any data value that goes up/down when a player looks in the direction of another player? If not, are you able to count how many players that are on a specific team in a set radius and then say that number through /tellraw?
Best Answer
Yes! There is!
If you're looking to teleport somebody, you can determine the direction that they're looking at with this syntax of the /tp command.
/tp @p [x] [y] [z] [x-look] [y-look]
If you're looking to select somebody looking in a certain direction, you can use the rx, rxm, ry and rym selector arguments.
For each selector, a float is required as the value to look for. The ry and rx arguments look for a player with a rotation lower than the given value, while the rxm and rym arguments look for a player with a rotation greater than the given value.
- The
rxandrxmarguments test for the player's horizontal rotation.
-90.0 being that he/she is looking straight down and 90.0 for straight up. - The
ryamdrymarguments test for the player's vertical rotation; whether they are looking North, South, East or West.
This system branches from the South direction (0d) and moves into negative/positive; East (-90d)/West (90d) and North (180d/-180d).
It also allows for in-betweens of multiples of 90 degrees, allowing freedom in testing for certain rotations, for example: 45d is South West.
For example, if I would like to test for a player that is looking North West, and straight ahead (at ground level), I would test for a rx and rxm of 0 (directly ahead) and a ry and rym of somewhere between North (180d) and West (90d); 135 degrees.
/testfor @a[rx=0,rxm=0,ry=135,rym=135] ...
Just note, that this command tests for exact rotation, which can be really hard to reach. It'd be better to give leeway either side, for example: 5 degrees.
/testfor @a[rx=5,rxm=-5,ry=140,rym=130] ...
If not, are you able to count how many players that are on a specific team in a set radius and then say that number through /tellraw?
This is also achievable. This time, add the team selector to your command, and to count, get each player to /execute @a[...] ~ ~ ~ scoreboard players add dummy count 1, assuming that you have a dummy player to take the count, have the score set to 0 and your counting scoreboard is count.
Pictures about "Minecraft Command help: testfor/execute questions [closed]"
![Minecraft Command help: testfor/execute questions [closed] - Man With Megaphone Pointing Minecraft Command help: testfor/execute questions [closed] - Man With Megaphone Pointing](/assets/images/minecraft_command_help_testforexecute_questions_closed_1.jpeg)
![Minecraft Command help: testfor/execute questions [closed] - Dog giving paw to anonymous person Minecraft Command help: testfor/execute questions [closed] - Dog giving paw to anonymous person](/assets/images/minecraft_command_help_testforexecute_questions_closed_2.jpeg)
![Minecraft Command help: testfor/execute questions [closed] - Close Up Photo of Computer Codes Minecraft Command help: testfor/execute questions [closed] - Close Up Photo of Computer Codes](/assets/images/minecraft_command_help_testforexecute_questions_closed_3.jpeg)
How do you use the command Testfor in Minecraft?
Type the command in the chat window and press the Enter key to run the command. Once the cheat has been entered, the testfor command will check for mooshrooms. You will see the message "Found Mooshroom" appear in the lower left corner of the game window for each mooshroom found within 50 blocks of you.What replaced the Testfor command in Minecraft?
The /testfor command became obsolete in Minecraft 1.13, and has been replaced by the /execute command*. It will do the same as typing /testfor @e {SelectedItem:{id:"<item>"}} and then putting a comparator to the command block with the command, and then running the command which you wanna run.How do you use the clear and fill command in Minecraft?
To do this, players can either use the F3 key on Minecraft: Java Edition or the "show coordinates" option in Bedrock Edition to note the start and end points of where they want the fill command to clear. In these syntaxes, <from> and <to> are the x/y/z coordinates of the starting point (from) to the ending point (to).What is the Minecraft execute command?
/execute executes another command but allows changing the executor, changing the position and angle it is executed at, adding preconditions, and storing its result.Minecraft Redstone Tutorial | How to use testfor commands in MCPE!
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pressmaster, Pressmaster, Leon Natan, Markus Spiske
