0

When using command blocks some commands ask for [Data value] and [Data tag]. I know what Data values are. But what are Data tags? How do translate the Data specifications that I need into "command block language"? And is there a rubric or reference page where I can find all of them so I won't have to bug you all with every specific thing I'm trying to do.

3

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.

  • Mention something about "NamedTag:{}" and "NamedTag:[{},{}]" or something, and I'll love this answer. :) – James Of Da Peach Feb 26 '14 at 12:29
  • @JamesOfDaPeach well, if you follow the 'grammar' I gave, deciphering combinations comes naturally. Nevertheless I have included a verbose example of breaking an expression down to its parts. It is really easier if you view the data tag as a tree with values (like folders and flies. The tree is converted to text using the above rules or 'grammar'. – Kcats Feb 26 '14 at 16:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.