0

Was wondering if it was possible to do this. I want to make a name tag or other item that, when dropped, will give the player the skull of the player specified in the name of the name tag. Is this possible in any way?

2 Answers 2

1

No, you cannot do that, because item names are stored as a JSON string, not a regular string. So when you name an item Steve in an anvil, its NBT data actually contains {"text":"Steve"}. This is useful if you wanted to colour names or do other fancy stuff with it, but in your case it's preventing you from doing what you want. And the game has no ways to manipulate a string (except for some complicated stuff that is not relevant here), not even converting it from JSON to a regular string.

But there are in fact two places where a Survival player can store a regular string: A writeable book page (only before signing, afterwards it becomes JSON) and a written book title (after signing). So you can for example instruct the player to name a book and then throw it.

I assume you probably have some mechanism of determining which item to select as the source of the name, so let's say you have it tagged with "source". Now you can first summon an item of a default player skull:

/summon item ~ ~ ~ {Item:{id:"player_head",Count:1},Tags:["target"]}

And then you can copy the name over:

/data modify entity @e[type=item,tag=target,limit=1] Item.tag.SkullOwner set from entity @e[type=item,tag=source,limit=1] Item.tag.title

And just in case the item still lies on the ground when the player wants to get another head, you should clean up the tag:

/tag @e[type=item,tag=target,limit=1] remove target

And you probably want to remove the thrown book:

/kill @e[type=item,tag=source]
1
  • I edited the answer, you can also use a book content (Item.tag.pages[0]) instead, if you want. It is a regular string as well, until you sign the book. Commented Mar 29, 2020 at 22:02
-1

I thinks it's /give @p minecraft:player_head{SkullOwner:<username>}

1
  • But how can I replace <username> with the name of my item via commands?
    – Sam Hill
    Commented Mar 29, 2020 at 3:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .