How do I use a target selector to output the nearest player's UUID?

I want to be able to use a target selector to select all of a player's tamed wolves. It's easy to do that with this target selector:

@e[type=wolf,nbt={"OwnerUUID":"<Player UUID>"}]

When I try to use the JSON selector string to specify the UUID like this:

@e[type=wolf,nbt={"OwnerUUID":{"selector":"@p"}}]

the selector string returns the nearest player's name. The OwnerUUID data value of the wolf obviously requires a UUID. Is there a potential workaround for this?


Solution 1:

You're confusing NBT and JSON. They have pretty similar syntax, but they are applied in different areas and with different "keys" and "values".

To my knowledge it is impossible to select all wolves of a specific player, because the wolf stores UUIDLeast and UUIDMost of the player, while the player entity stores UUID. Those can be converted, but not with commands, because UUID is a string.

The best you can do is saving all wolves tamed in the future by using the advancement trigger tame_animal](https://minecraft.gamepedia.com/Advancements/List_of_triggers#minecraft:tame_animal) (archive).