Command to say player coords in chat?

Command to say player coords in chat? - Sportsmen in red and blue waistcoats chatting on floor of spacious curling arena

Trying to get a command that tells a player's coords in chat. I have a working command: /data get entity @s Pos, but I assume I would need to combine this with /tellraw?



Best Answer

You can do that using just tellraw:

/execute as @p run tellraw @a [{"selector":"@s"},{"text":"'s coordinates are X:"},{"nbt":"Pos[0]","entity":"@s"},{"text":" Y:"},{"nbt":"Pos[1]","entity":"@s"},{"text":" Z:"},{"nbt":"Pos[2]","entity":"@s"}]

That is going to display the coordinates but in the form of a decimal number with a lot of digits. If you want to display whole numbers, what you can do is store the values into scoreboard objectives (storing them converts them to integers) and then display the objectives using /tellraw.

This is how you store the coordinates into objectives:

/execute store result score @s x run data get entity @s Pos[0]
/execute store result score @s y run data get entity @s Pos[1]
/execute store result score @s z run data get entity @s Pos[2]

And this is how you display the values:

/execute as @p run tellraw @a [{"selector":"@s"},{"text":"'s coordinates are X:"},{"score":{"name":"@s","objective":"x"}},{"text":" Y:"},{"score":{"name":"@s","objective":"y"}},{"text":" Z:"},{"score":{"name":"@s","objective":"z"}}]



Pictures about "Command to say player coords in chat?"

Command to say player coords in chat? - Group of sitting people spending time in curling arena
Command to say player coords in chat? - Talking curler players chilling on floor
Command to say player coords in chat? - A Man in Green Crew Neck T-shirt Playing Computer Games



How do you show coordinates in chat?

You can see coordinates in the upper left corner of any map held. Otherwise, you can show coordinates by typing \u201c/tp ~ ~ ~\u201d into the chat box. The method needed to view coordinates depends on which platform you're using to play Minecraft.

How do you talk in coordinates in Minecraft chat?

0) you can use the command /tp ~ ~ ~ , which teleports the current player to the current location. This command has the side effect of displaying the coordinates it teleported to.

How do you find player coordinates in Minecraft with commands?

Also, you can't get their exact coordinates. If you are targeting a specific player in a command, simply type their name on the <Player> tag or do @p for nearest player, @r for random player or @a for all players.



How To Make Command Blocks Say Custom Words [On Screen AND in Chat!]




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: SHVETS production, SHVETS production, SHVETS production, Yan Krukov