When a text display entity is summoned, it ignores both the execution context of the command and its own position when resolving the text components on it. Instead they are always resolved with a default position of 0 0 0
.
For comparison, sign blocks use their own position when resolving text components.
How to reproduce
1. Prepare the world by creating things to detect at 0 0 0
/forceload add 0 0
/summon marker 0 0 0 {CustomName:'"Fail 1"'}
/setblock 0 0 0 command_block{CustomName:'"Fail 2"'}
2. Summon the text display
/summon text_display ~ ~ ~ {text:'[{"selector":"@e[sort=nearest,limit=1]"},", ",{"nbt":"CustomName","block":"~ ~ ~","interpret":true}]'}
3. Compare what is displayed on the new entity with the output of the equivalent tellraw
command. Expected is that they would match
/tellraw @p [{"selector":"@e[sort=nearest,limit=1]"},", ",{"nbt":"CustomName","block":"~ ~ ~","interpret":true}]
Comments 3
The thing is, the x y z arguments are the position; having to write Pos to have it resolve correctly is incredebly wrong.
it seems that i know why it happens. the root of the problem is that you did not write Pos in summon`s NBT.
i tried this:
and it finds me. (i was standing near 10 10 10)