I'm using a command like this:
/execute @e[type=ArmorStand] ~ ~ ~ tellraw @a[score_goto=-1]
{
"selector": "@e[type=ArmorStand,r=1]",
"clickEvent": {
"action": "run_command",
"value": "/tp @p ~ ~ ~"
},
"color":"blue"
}
To try and make each armor stand in the world say their name (in blue), and, if the player clicks the armor stand's name in-chat they will be teleported to that armor stand.
Currently, it looks like this:
And, when I click either of the two names, I'd like to be teleported to that armor stand, hence the
"clickEvent":{"action":"run_command","value":"/tp @p ~ ~ ~"}
part within the command.
However, because run_command
apparently only inserts the command into the player's chat, I just get teleported to wherever I currently am when I click any name.
So, I tried:
"clickEvent": {
"action": "run_command",
"value": [
"/tp @p @e[type=ArmorStand,name=",
{"selector": "@e[type=ArmorStand,r=1"},
"]"
]
}
Thinking that maybe the JSON in value would be parsed, producing my desired value of
"value": "/tp @p @e[type=ArmorStand,name=Name_Of_This_Armor_Stand]"
but no luck.
Everything I've tried just doesn't seem to work, can someone please help me find a way to make a tellraw clickEvent teleport the player to the entity which executed the tellraw command?
TL;DR
Please help me find a way to make a tellraw clickEvent teleport the player to the entity which executed the tellraw command?
run_command
uses whatever privileges the user has, and only ops cantp
./tp @p ~ ~2 ~
will always teleport@p
2 blocks up from@p
, rather than 2 blocks up from the executer of the command like how relative coordinates in other commands would work.Can't think of a simple way to do this
- nether can I, that's why I'm asking here; I think, by this point, "simple" is completely out of the question. Also, my armor stands already have names, and an execute command is already runningtellraw
for each armor stand. I disagree that Mojang's implementation of thetp
command is inconsistent; it works exactly as one'd expect. It's just in this case, I need a way for the tellraw-er to run a command, as opposed to the player.clickEvent:{value:}
, but there isn't a way to do that.