How do you test if a player is holding a Skull with a skull owner?
I am trying to make it so that when the boss gets killed, it drops an item. Then it is supposed to test that item and if they have it, they can move on to the next boss. But my item is a Skull with a Skull owner. So a player head. But I am not sure how to test that.
The SkullOwner
string tag is translated into a compound tag containing information that will not be possible to detect anew. The new data is a Base64 encoded object stored as a single string, and includes a timestamp of creation. As well, it also includes a link to the skin file, which may change if the skin is ever changed.
You should instead assign a custom tag to the skull and detect that custom tag rather than any normal data.
For example, summoning a zombie with that item, having a custom byte tag called BOSSITEM
:
/summon Zombie ~ ~1 ~ {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1b,Damage:3s,tag:{SkullOwner:"Skylinerw",BOSSITEM:1b}}]}
And detecting if the item is in a player's inventory would involve just checking the custom tag, as it represents the item as a whole:
/testfor @a {Inventory:[{tag:{BOSSITEM:1b}}]}
To clarify: the compound data never changes once it's made, so you could summon the mob with the skull owner already translated and detect that translated data instead, but it will be more complicated to detect and will force you to change both creation and detection commands if you ever want to change the skin. You should use custom data instead, as shown above.
But just as an example with compound data, with the summoned zombie:
/summon Zombie ~ ~1 ~ {ArmorItems:[{},{},{},{id:"minecraft:skull",Count:1b,Damage:3s,tag:{SkullOwner:{Id:"b9aa57fe-649e-4d48-806e-63af2faff5c6",Properties:{textures:[{Value:"eyJ0aW1lc3RhbXAiOjE0NzAyNjUyOTI1NjEsInByb2ZpbGVJZCI6ImI5YWE1N2ZlNjQ5ZTRkNDg4MDZlNjNhZjJmYWZmNWM2IiwicHJvZmlsZU5hbWUiOiJTa3lsaW5lcnciLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTc0MzhiZDE1NjI2MTk1N2NhOTQ0Mzg5ZGQ3OWYwZjAyY2E5NDU4M2YwZjQyMGMxZmY5YTllMmM1OTRhMTQifX19"}]},Name:"Skylinerw"}}}]}
And detection (where you essentially only need the Base64 object):
/testfor @a {Inventory:[{tag:{SkullOwner:{Properties:{textures:[{Value:"eyJ0aW1lc3RhbXAiOjE0NzAyNjUyOTI1NjEsInByb2ZpbGVJZCI6ImI5YWE1N2ZlNjQ5ZTRkNDg4MDZlNjNhZjJmYWZmNWM2IiwicHJvZmlsZU5hbWUiOiJTa3lsaW5lcnciLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTc0MzhiZDE1NjI2MTk1N2NhOTQ0Mzg5ZGQ3OWYwZjAyY2E5NDU4M2YwZjQyMGMxZmY5YTllMmM1OTRhMTQifX19"}]}}}}]}