Minecraft – How to find the item tag?

minecraft-commandsminecraft-java-edition

I'm currently working on some maps, but I always find myself lost when I'm trying to find a specific item in a slot in my inventory.

This time it's the head, which is 103b. Currently, I don't have any way to check for it, so all I'm doing is checking for a skull, which makes it easy to bypass.

Here is an example:

/scoreboard players set @a Hulk 1 {Inventory:[{Slot:103b,id:"minecraft:skull"}]}

This is an easy way to find the skull, but I want it to be more specific. For example, a skull with a name, enchantments, etc.

This is the specific item I'm looking for:

/give @p minecraft:skull 1 3 {HideFlags:1,display:{Name:"The Hulk",Lore:[The head of the Hulk]},SkullOwner:Oconna,ench:[{id:0,lvl:10}]}

But since I can't copy {HideFlags:1,display:{Name:"The Hulk",Lore:[The head of the Hulk]},SkullOwner:Oconna,ench:[{id:0,lvl:10}]} into the other command (which would result in this):

/scoreboard players set @a Hulk 1 {HideFlags:1,display:{Name:"The Hulk",Lore:[The head of the Hulk]},SkullOwner:Oconna,ench:[{id:0,lvl:10}]}

I can't find it easily.

Is there any way to easily find a head with specific attributes, or do I need to type it all down?

Best Answer

The item-specific data is stored in the tag tag, meaning you'll have to add

tag:{HideFlags:1,display:{Name:"The Hulk",Lore:[The head of the Hulk]},SkullOwner:Oconna,ench:[{id:0,lvl:10}]}

to the id and Slot tags in the scoreboard command (cf. Item Structure), as shown below.

/scoreboard players set @a Hulk 1 
{
    Inventory:[
    {
        Slot:103b,
        id:"minecraft:skull",
        tag:
        {
            HideFlags:1,
            display:{Name:"The Hulk",Lore:[The head of the Hulk]},
            SkullOwner:Oconna,
            ench:[{id:0,lvl:10}]
        }
    }]
}

Non-exploded view for copy-pasting:

/scoreboard players set @a Hulk 1 {Inventory:[{Slot:103b,id:"minecraft:skull",tag:{HideFlags:1,display:{Name:"The Hulk",Lore:[The head of the Hulk]},SkullOwner:Oconna,ench:[{id:0,lvl:10}]}}]}