Is there a way I can testfor an entities coordinates, then use /tellraw to put the coordinates in the chat?
Is there a way I can /testfor an entities coordinates, then use /tellraw to put the coordinates in the chat?
For example, if I use /spreadplayers ~ ~ 50000 50001 false @e[type=ArmorStand,r=1]
After it has teleported can I have the game detect its coordinates, and say them in chat?
Best Answer
Not easily.
You'll have to convert the player's position into a scoreboard objective first and then use that. There are no simple ways to do this.
The fastest way I can think of would be using an armorstand as a copy of the player, and teleport it around to figure out where it is using powers of 2: Check if x>256, increment score, teleport by -256, check if x>128, and so on...
That would require about 3×2log(Xmax-Xmin) command blocks for x, where Xmax and Xmin are the highest and lowest possible coordinates, and similar numbers for y and z. For a 256x256x256 cube, you are looking at (3×8)×3=72 command blocks.
To be multiplayer (or multi-entity)-friendly, you'll need to either perfectly identify every such armor stand to a player, or else do it sequentially for every player. Dealing with negative coordinates is another problem.
Pictures about "Is there a way I can testfor an entities coordinates, then use /tellraw to put the coordinates in the chat?"



How do you type in coordinates in Minecraft chat?
How to Enter the CommandDo command blocks have a range?
Range 2 is the range a player want for a command block under a floor. Keep in mind that it will produce a globe shaped trigger area (rather than a cube), so a range of 2 makes an approximately 5\xd75\xd75 area and a range of 1 makes a 3\xd73\xd73 area (more like a + pattern with an extra block above and below the center).Minecraft Command Basics: /tp and Coordinates
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Ketut Subiyanto, SHVETS production, Andrea Piacquadio, MART PRODUCTION
