Minecraft command block specifiers "[Data value] [Data tag]"? [duplicate]

Solution 1:

Data tags give you access to the (formerly) internal data for each entity or block. You can pretty much do anything (that is possible in the game engine) by modifying the data tags. For example, if you want a white horse:

/summon EntityHorse ~ ~ ~ {Variant:0}

If you want the horse to be tame and have a saddle:

/summon EntityHorse ~ ~ ~ {Variant:0,Tame:1,Saddle:true}

If you want to give the player a named shovel with Fortune X enchantment:

/give @p iron_pickaxe 1 0 {ench:[{id:35,lvl:10}],display:{Name:Lucky}}

The list of all possible tags is here: http://minecraft.gamepedia.com/Chunk_format.


The format is the following:

DataTag is { NamedTag , NamedTag,... }
NamedTag is TagName : TagValue
TagName is the tag name as seen in the above link (case sensitive)
TagValue is number or string or DataTag or ValueList
ValueList is [ TagValue , TagValue ,...]


Using this 'grammar' we can break down the example {ench:[{id:35,lvl:10}],display:{Name:Lucky}} into its parts: It is a DataTag that has two NamedTag-s: ench:[{id:35,lvl:10}] and display:{Name:Lucky}

The first NamedTag's name is ench and its value is [{id:35,lvl:10}]. This value is a list with one item (we have one enchantment). The item is {id:35,lvl:10} and it is itself a DataTag. It has its own two NamedTag-s: id:35 and lvl:10 which show the enchantment id is 35 - Fortune and enchantment level is 10. If we want to add another enchantment to the shovel, we need to build a DataTag for it: e.g. for knockback {id:19,lvl:5}. Then we need to put the second enchantment in the list: [{id:35,lvl:10},{id:19,lvl:5}]

The second NamedTag of the root tag has name display and value {Name:Lucky}. This value is itself a DataTag that contains only one NamedTag - Name:Lucky. This NamedTag has name Name and value Lucky.