How to /tell a Player an NBT property of a item on 1.12.2?

How to /tell a Player an NBT property of a item on 1.12.2? - Unpacked boxes in middle of room

I'm trying to create a small basketball game on my server (from scratch to learn command blocks).

To test that it's working, I'm trying to have the Basketball item tell me who threw it. However, whenever I try this:

/execute @e[type=item,r=3] ~ ~ ~ /tell @p @s [{Thrower}]

it doesn't work.

Is it possible to have a NBT tag property in a tell command? Or is there something else I have to do?

I'm on version 1.12.2


Best Answer

Tell only lets you write simple text, if you want to give some more advanced information, you need to use tellraw with RawJSONText instead.
Including data inside the tellraw currently only works in Java Edition and there also only in 1.14 and above, as Bedrock doesn't give access to internal data structures and the data option of tellraw was added in 1.14.

So for example you can do

/execute as @e[type=item,distance=..3] run tellraw @a [{"nbt": "Thrower", "entity": "@s"}]

It will output the UUID of the player who threw the item in the form of an integer array.




Pictures about "How to /tell a Player an NBT property of a item on 1.12.2?"

How to /tell a Player an NBT property of a item on 1.12.2? - Woman cutting off adhesive tape from box with parcel
How to /tell a Player an NBT property of a item on 1.12.2? - Interior of stylish living room with comfortable couch placed near shelf with collection of vintage vinyl records and wooden cabinet decorated with classic table lamp
How to /tell a Player an NBT property of a item on 1.12.2? - Metal lamp hanging near wall with colorful leaves in room in new flat



How do you see the NBT of an item in Minecraft?

To see an Item NBT tag just activate the advanced tooltips by pressing F3+H, the tag will appear inside the tooltip. Longer tags will be presented in an auto scrolling view, the scroll speed can be controlled with SHIFT, to pause scrolling, and ALT, to speed it up.

How do I get NBT data of an entity?

You can use the /data command to get, merge and remove NBT tags (formerly called data tags) for entities and block entities. The /data command is most useful for changing attributes of a mob after the mob has spawned or modifying attributes of a block entity after you have placed it.



Item Attributes/NBT Tags! - 1.12 Beginner Command Block Tutorial Episode 13




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

Images: Ketut Subiyanto, Liza Summer, Charlotte May, Max Vakhtbovych