Difference between revisions of "Data tags"

From Mine Blocks Wiki
Jump to navigation Jump to search
If you find a typo, inconsistency, or error, please sign up and help out the wiki! We can't do it without your help! :D Thank you!

(Added history table)
(Added 1.29.1 info)
 
(10 intermediate revisions by 2 users not shown)
Line 5: Line 5:
  
 
An example of a give command using data tags:
 
An example of a give command using data tags:
 +
 +
=== Item tags example ===
 +
This command gives the player a purple Leather Cap named "Purple Hat" that has the two enchantments "Unbreaking II" and "Fire Protection III":
  
 
<code>give leather_cap 1 0 {type:"purple", name:"Purple Hat", enchantments:["unbreaking2", "Fire Protection III"]}</code>
 
<code>give leather_cap 1 0 {type:"purple", name:"Purple Hat", enchantments:["unbreaking2", "Fire Protection III"]}</code>
 +
 +
=== Block tags example ===
 +
This command places a chest near the player named "Lemon Chest" full of iron pickaxes with only one use left:
 +
 +
<code>setblock chest ~1 ~-1 {name:"Lemon Chest", items:{id:"iron_pickaxe", damage:-1}}</code>
 +
 +
=== Mob tags and loot tags example ===
 +
This command spawns a pig spawnskin named "Fake Pig" that has 10 health and drops 1-3 "Fake" porkchops:
 +
 +
<code>summon spawnskin 1 ~ ~ {skin:15868, name:"Fake Pig", health:10, drops:[{item:{id:"porkchop", name:"Fake Pork"}, quantity:1, bonus:2}]}</code>
  
 
== Tags ==
 
== Tags ==
  
 +
=== Item Tags ===
 
Listed below are all the data tags that can be applied to items.
 
Listed below are all the data tags that can be applied to items.
  
Line 21: Line 35:
 
|''String''
 
|''String''
  
<code>mob_egg</code>: The mob spawned by the egg ("zombie", "ender dragon", "nethereye")
+
<code>spawn_egg</code>: The mob spawned by the egg ("zombie", "ender dragon", "nethereye")
  
 
<code>potion</code>: Specifies the type of potion ("empty", "water", "fire protection +")
 
<code>potion</code>: Specifies the type of potion ("empty", "water", "fire protection +")
Line 52: Line 66:
 
|-
 
|-
 
|<code>name</code>
 
|<code>name</code>
|Overrides the default naming of the item (as if it was renamed by an anvil)
+
|Overrides the default naming of the item (as if it was renamed by an anvil).
 
|''String''
 
|''String''
  
 
Applies to all items.
 
Applies to all items.
 +
|-
 +
|<code>canDestroy</code>
 +
|Specifies the id of the block the item can destroy.
 +
|''String''
 +
 +
Applies to any item. The specified id has to be that of a block.
 +
|-
 +
|<code>canPlaceOn</code>
 +
|Specifies the id of the block which the item can be placed.
 +
|''String''
 +
 +
Only applies blocks. The specified id has to be that of a block.
 
|-
 
|-
 
|<code>showParticles</code>
 
|<code>showParticles</code>
Line 62: Line 88:
  
 
Only applies to <code>potion</code>. Value is simply omitted when true.
 
Only applies to <code>potion</code>. Value is simply omitted when true.
 +
|-
 +
|<code>category</code>
 +
|Specifies the category of certain items.
 +
|''String''
 +
 +
Only applies to <code>potion</code>. Potions with the "splash" category are [[splash potions]].
 
|-
 
|-
 
|<code>command</code>
 
|<code>command</code>
Line 76: Line 108:
 
|}
 
|}
  
=== Colors Tags ===
+
=== Block Tags ===
For colored items, the color is specified using the <code>type</code> data tag.
+
Listed below are all the data tags that can be applied to blocks.
 +
 
 +
{| class="wikitable"
 +
!Tag Name
 +
!Description
 +
!Values and Applicable Blocks
 +
|-
 +
|<code>type</code>
 +
|Specifies the type of the block. Oftentimes this is the color of the block, such as wool. If the value is invalid for the item, the value will be omitted.
 +
|''String''
 +
 
 +
<code>dye</code>, <code>glass</code>, <code>glass_backdrop</code>: Color ("red", "purple", "light gray")
 +
 
 +
<code>carpet</code>, <code>wool</code>, <code>wool_backdrop</code>: Color, or "rainbow"
 +
 
 +
<code>mob_head</code>: Creeper, zombie, skeleton, enderdragon, or skin ID
 +
 
 +
|-
 +
|<code>name</code>
 +
|Specifies the display name of a container block (such as a chest), as if it was renamed by an anvil.
 +
|''String''
 +
 
 +
Applies to <code>chest</code>, <code>furnace</code>, <code>brewing_stand</code>, <code>enchantment_table</code>, <code>dropper</code>, <code>dispenser</code>.
 +
 
 +
|-
 +
|<code>growth</code>
 +
|Specifies the growth stage of a crop.
 +
|''Integer''
 +
 
 +
Applies to <code>melon_seed</code>, <code>pumpkin_seed</code>, <code>seeds</code>, <code>carrot</code>, <code>potato</code>, <code>nether_wart</code>, <code>beetroot_seeds</code>. Value clamped to range 1-7.
 +
 
 +
|-
 +
|<code>text</code>
 +
|Defines the writing on a sign.
 +
|''String''
 +
 
 +
Applies only to <code>sign</code>.
 +
 
 +
|-
 +
|<code>damage</code>
 +
|Specifies the damage state of an anvil.
 +
|''Integer''
 +
 
 +
Applies only to <code>anvil</code>. Value clamped to range 1-3.
 +
 
 +
|-
 +
|<code>items</code>
 +
|Defines the items inside of the container.
 +
|''Item Data'' or ''Array of Item Data''
 +
 
 +
<code>chest</code> is an array of 27 item data.
 +
 
 +
<code>dropper</code> and <code>dispenser</code> are an array of 9 item data.
 +
 
 +
If the value is an item data without an array, the item will be duplicated for each item slot.
 +
 
 +
|-
 +
|<code>input</code>
 +
|Defines the input item of a block.
 +
|''Item Data''
 +
 
 +
<code>furnace</code> accepts any item that can be smelted.
 +
 
 +
<code>brewing_stand</code> accepts any brewing ingredient.
 +
 
 +
If the value is an item data without an array, the item will be duplicated for each item slot.
 +
 
 +
|-
 +
|<code>fuel</code>
 +
|Defines the fuel item of a block.
 +
|''Item Data''
 +
 
 +
<code>furnace</code> accepts any fuel.
 +
 
 +
<code>brewing_stand</code> only accepts blaze powder.
 +
 
 +
|-
 +
|<code>output</code>
 +
|Defines the output item(s) of a block.
 +
|''Item Data'' or ''Array of Item Data'' (for <code>brewing_stand</code>)
 +
 
 +
<code>furnace</code> accepts any item.
 +
 
 +
<code>brewing_stand</code> accepts <code>potion</code>s. If the value is an item data without an array, the item will be duplicated for each item slot.
 +
 
 +
|-
 +
|<code>activated</code>
 +
|Defines whether a block is activated.
 +
|''Boolean''
 +
 
 +
Only applies to the switch state of a <code>lever</code>
 +
|-
 +
|<code>facing</code>
 +
|Determines the orientation of a block.
 +
|''String''
 +
 
 +
<code>coral_lantern</code>, <code>torch</code>, <code>odd_rock_torch</code>, <code>redstone_torch</code>, <code>button</code>, <code>lever</code>: "left", "right", or "up".
 +
 
 +
<code>piston</code>, <code>piston_sticky</code>, <code>hay</code>, <code>wood</code>: "left", "right", "up", or "down".
 +
 
 +
Any <code>_stair</code> block: "left", "right", "upleft", "upright", "downleft", or "downright".
 +
 
 +
Any <code>_slab</code> block: "up", or "down".
 +
 
 +
<code>mob_head</code>: "left" or "right".
 +
 
 +
|}
 +
 
 +
 
 +
=== Mob Tags ===
 +
Listed below are all the mob tags that can be applied to mobs.
 +
 
 +
{| class="wikitable"
 +
!Tag Name
 +
!Description
 +
!Values and Applicable Mobs
 +
|-
 +
|<code>name</code>
 +
|Specifies the name of the mob, as though applied via a [[name tag]].
 +
|''String''
 +
 
 +
Applies to all mobs.
 +
 
 +
|-
 +
|<code>health</code>
 +
|Specifies the current health of the mob.
 +
|''Integer''
 +
 
 +
Applies to all mobs. The minimum value is 1, however the value is not capped at the maximum health for the spawned mob type. When a mob's health is above the maximum, healing the mob will be ineffectual. The max health of a mob cannot be changed.
 +
 
 +
|-
 +
|<code>holding</code>
 +
|Specifies the item in the mob's hand slot.
 +
|''Item Data'' or ''String''
 +
 
 +
Applies only to [[enderman|endermen]] and [[zombie pigman|zombie pigmen]]. If ''String'' is specified in place of the item data, a single item matching the value's identifier will be given to the mob.
 +
 
 +
|-
 +
|<code>defaultDrops</code>
 +
|Specifies whether or not the mob will drop their default items upon death.
 +
 
 +
Often used in combination with <code>drops</code> for overriding the drops of a mob.
 +
|''Boolean''
 +
 
 +
Applies to all mobs.
 +
 
 +
|-
 +
|<code>drops</code>
 +
|Specifies the loot the mob will drop upon death.
 +
|''Array of Loot Data''
 +
 
 +
Applies to all mobs.
 +
 
 +
See [[#loot_tags|Loot Tags]] for more details.
 +
 
 +
Often used in combination with <code>defaultDrops:false</code> for overriding the drops of a mob.
 +
 
 +
|-
 +
|<code>skin</code>
 +
|Specifies the skin ID for <code>spawnskin</code> mobs.
 +
|''Integer''
 +
 
 +
Applies only to <code>spawnskin</code>.
 +
 
 +
|-
 +
|<code>charged</code>
 +
|Determines whether or not a creeper is charged.
 +
|''Boolean''
 +
 
 +
Applies only to <code>creeper</code>.
 +
 
 +
|-
 +
|<code>baby</code>
 +
|Specifies if the mob is spawned as a baby.
 +
|''Boolean''
 +
 
 +
Applies to <code>chicken</code>, <code>sheep</code>, <code>rabbit</code>, <code>pig</code>, <code>wolf</code>, <code>cow</code>, <code>mooshroom</code>, and <code>cowctus</code>.
 +
 
 +
|}
 +
 
 +
=== Loot Tags ===
 +
Listed below are all the tags that are used in loot tables.
 +
 
 +
{| class="wikitable"
 +
!Tag Name
 +
!Description
 +
!Values and Applicable Situations
 +
|-
 +
|<code>item</code>
 +
|This is the item that is produced if the conditions are right for the item to be dropped.
 +
|''Item Data'' or ''String''
 +
 
 +
Must be in all loot tags.
 +
 
 +
|-
 +
|<code>quantity</code>
 +
|The minimum number of times the item drops (if the conditions are met). Defaults to 1.
 +
|''Int''
 +
 
 +
|-
 +
|<code>bonus</code>
 +
|A random number of extra items can be dropped up to the specified value (if the conditions are met). Defaults to 0.
 +
 
 +
The calculation of extra items is as expected: <code>floor(random()*(bonus + 1))</code>
 +
|''Int''
 +
 
 +
|-
 +
|<code>lootBonus</code>
 +
|A random number of extra items can be dropped at max looting enchantment (if the conditions are met) up to the specified value. Defaults to 0.
 +
 
 +
The calculation of extra items is as follows: <code>floor((random()*.6 + .4)*lootLevel/3*(loot + 1))</code>
 +
 
 +
|''Int''
 +
 
 +
|-
 +
|<code>chance</code>
 +
|''A success condition''
 +
 
 +
This adds a random chance that the loot will drop. If the condition is not met, the loot will not be dropped.
 +
 
 +
The procedure is as follows:
 +
* Generate a random number for the given <code>seed</code> if it doesn't already exists
 +
* Calculate chance: <code>random(seed)*(1 - lootOffset*lootLevel/3)</code>
 +
* Succeed condition if <code>chance >= min</code> and <code>chance < max</code>
 +
 
 +
Using the same seed can allow a loot table to drop one item or another one, but never both.
 +
|''Object''
 +
 
 +
The chance object is as follows (with default values):
 +
<code>{seed:0, min:0, max:1, lootOffset:0}</code>
 +
 
 +
<code>seed</code> determines which random number to use.
 +
<code>min</code> determines the lower bound to succeed the check.
 +
<code>max</code> determines the upper bound to succeed the check.
 +
<code>lootOffset</code> reduces the range of the random number per level of looting
 +
 
 +
|-
 +
|<code>variant</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if the mob variant matches the killed mob.
 +
|''String''
 +
 
 +
Only applies to mobs with variants. Accepts "normal", "mooshroom", and "cowctus".
 +
 
 +
|-
 +
|<code>sheared</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if the mob is or is not sheared, depending on the value.
 +
|''Boolean''
 +
 
 +
Applies to the <code>sheep</code> mob.
 +
 
 +
|-
 +
|<code>isBaby</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if the mob is or is not a baby, depending on the value.
 +
|''Boolean''
 +
 
 +
Applies to all mobs.
 +
 
 +
|-
 +
|<code>color</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if the color of the object matches, depending on the value.
 +
|''Color''
 +
 
 +
Only applies to <code>sheep</code> and <code>dog</code> mobs.
 +
 
 +
|-
 +
|<code>onFire</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if object is on fire.
 +
|''Boolean''
 +
 
 +
Applies to all mobs.
 +
 
 +
|-
 +
|<code>size</code>
 +
|''A success condition''
 +
 
 +
Only drops the item if a mob's size matches the value.
 +
|''Int''
 +
 
 +
Only applies to <code>magma_cube</code> and <code>slime</code>.
 +
 
 +
|}
 +
 
 +
 
 +
=== Colors Values ===
 +
For colored [[items]] or [[blocks]], the color is specified using the <code>type</code> data tag.
 
{{Colors|rainbow=true}}
 
{{Colors|rainbow=true}}
  
Line 92: Line 418:
 
|-
 
|-
 
! [[Version History#1.28|1.28]]
 
! [[Version History#1.28|1.28]]
! Oct 8, 2016
+
! Oct 08, 2016
 
|
 
|
 
* Data tags can be specified when using the <code>/give</code> command
 
* Data tags can be specified when using the <code>/give</code> command
 +
|-
 +
! [[Version History#1.29|1.29]]
 +
! Sep 27, 2019
 +
|
 +
* New item data tags: "canDestroy" and "canPlaceOn"
 +
* Unbreakable works on armor again
 +
* Added data tags for blocks, mobs, and mob loot
 +
 +
|-
 +
![[Version History#1.29.1|1.29.1]]
 +
!Oct 05, 2019
 +
|
 +
* Fixed being unable to pick up items matching against blank data tags
 +
* Loot data tag "chance" now applies to drop table
 +
* Block data tag "powered" renamed to "activated"
 
|}
 
|}
  

Latest revision as of 13:26, 6 October 2019

Data tags are pieces of information that get stored on items and blocks. Tags are used to alter items in various ways, such as in appearance or in functionality.

Usage

Data tags can be applied to items by using the give command. They are the fourth parameter.

An example of a give command using data tags:

Item tags example

This command gives the player a purple Leather Cap named "Purple Hat" that has the two enchantments "Unbreaking II" and "Fire Protection III":

give leather_cap 1 0 {type:"purple", name:"Purple Hat", enchantments:["unbreaking2", "Fire Protection III"]}

Block tags example

This command places a chest near the player named "Lemon Chest" full of iron pickaxes with only one use left:

setblock chest ~1 ~-1 {name:"Lemon Chest", items:{id:"iron_pickaxe", damage:-1}}

Mob tags and loot tags example

This command spawns a pig spawnskin named "Fake Pig" that has 10 health and drops 1-3 "Fake" porkchops:

summon spawnskin 1 ~ ~ {skin:15868, name:"Fake Pig", health:10, drops:[{item:{id:"porkchop", name:"Fake Pork"}, quantity:1, bonus:2}]}

Tags

Item Tags

Listed below are all the data tags that can be applied to items.

Tag Name Description Values and Applicable Items
type Specifies the type of the item. Oftentimes this is the color of the item, such as wool. If the value is invalid for the item, the value will be omitted. String

spawn_egg: The mob spawned by the egg ("zombie", "ender dragon", "nethereye")

potion: Specifies the type of potion ("empty", "water", "fire protection +")

dye, glass, glass_backdrop, leather_boots, leather_pants, leather_tunic, leather_cap: Color ("red", "purple", "light gray")

carpet, wool, wool_backdrop: Color, or "rainbow"

balloon: Color, or "ghast"

unbreakable If enabled, and the item is a tool, the item will never lose durability. Boolean

Applies to all tools. Value is simply omitted when false.

enchantments A list of enchantments applied to the item. Array of Strings

Applies to all items. Both "unbreaking1" and "Unbreaking I" will refer to the same enchantment. Duplicate enchantments are ignored.

See enchanting for a list of enchantment identifiers.

anvilUses Specifies the number of times the item has been used in an anvil. This only affects the cost of using an anvil on the item. Integer

Applies to all items.

name Overrides the default naming of the item (as if it was renamed by an anvil). String

Applies to all items.

canDestroy Specifies the id of the block the item can destroy. String

Applies to any item. The specified id has to be that of a block.

canPlaceOn Specifies the id of the block which the item can be placed. String

Only applies blocks. The specified id has to be that of a block.

showParticles When disabled, this will hide the particles of potion effects when a potion is drank. Boolean

Only applies to potion. Value is simply omitted when true.

category Specifies the category of certain items. String

Only applies to potion. Potions with the "splash" category are splash potions.

command Specifies the command run by a command book. String

Only applies to command_book. Command will not be checked for errors upon creation.

uses Specifies how many times a command book can be used before it disappears. Integer

Only applies to command_book. Non-positive numbers are invalid.

Block Tags

Listed below are all the data tags that can be applied to blocks.

Tag Name Description Values and Applicable Blocks
type Specifies the type of the block. Oftentimes this is the color of the block, such as wool. If the value is invalid for the item, the value will be omitted. String

dye, glass, glass_backdrop: Color ("red", "purple", "light gray")

carpet, wool, wool_backdrop: Color, or "rainbow"

mob_head: Creeper, zombie, skeleton, enderdragon, or skin ID

name Specifies the display name of a container block (such as a chest), as if it was renamed by an anvil. String

Applies to chest, furnace, brewing_stand, enchantment_table, dropper, dispenser.

growth Specifies the growth stage of a crop. Integer

Applies to melon_seed, pumpkin_seed, seeds, carrot, potato, nether_wart, beetroot_seeds. Value clamped to range 1-7.

text Defines the writing on a sign. String

Applies only to sign.

damage Specifies the damage state of an anvil. Integer

Applies only to anvil. Value clamped to range 1-3.

items Defines the items inside of the container. Item Data or Array of Item Data

chest is an array of 27 item data.

dropper and dispenser are an array of 9 item data.

If the value is an item data without an array, the item will be duplicated for each item slot.

input Defines the input item of a block. Item Data

furnace accepts any item that can be smelted.

brewing_stand accepts any brewing ingredient.

If the value is an item data without an array, the item will be duplicated for each item slot.

fuel Defines the fuel item of a block. Item Data

furnace accepts any fuel.

brewing_stand only accepts blaze powder.

output Defines the output item(s) of a block. Item Data or Array of Item Data (for brewing_stand)

furnace accepts any item.

brewing_stand accepts potions. If the value is an item data without an array, the item will be duplicated for each item slot.

activated Defines whether a block is activated. Boolean

Only applies to the switch state of a lever

facing Determines the orientation of a block. String

coral_lantern, torch, odd_rock_torch, redstone_torch, button, lever: "left", "right", or "up".

piston, piston_sticky, hay, wood: "left", "right", "up", or "down".

Any _stair block: "left", "right", "upleft", "upright", "downleft", or "downright".

Any _slab block: "up", or "down".

mob_head: "left" or "right".


Mob Tags

Listed below are all the mob tags that can be applied to mobs.

Tag Name Description Values and Applicable Mobs
name Specifies the name of the mob, as though applied via a name tag. String

Applies to all mobs.

health Specifies the current health of the mob. Integer

Applies to all mobs. The minimum value is 1, however the value is not capped at the maximum health for the spawned mob type. When a mob's health is above the maximum, healing the mob will be ineffectual. The max health of a mob cannot be changed.

holding Specifies the item in the mob's hand slot. Item Data or String

Applies only to endermen and zombie pigmen. If String is specified in place of the item data, a single item matching the value's identifier will be given to the mob.

defaultDrops Specifies whether or not the mob will drop their default items upon death.

Often used in combination with drops for overriding the drops of a mob.

Boolean

Applies to all mobs.

drops Specifies the loot the mob will drop upon death. Array of Loot Data

Applies to all mobs.

See Loot Tags for more details.

Often used in combination with defaultDrops:false for overriding the drops of a mob.

skin Specifies the skin ID for spawnskin mobs. Integer

Applies only to spawnskin.

charged Determines whether or not a creeper is charged. Boolean

Applies only to creeper.

baby Specifies if the mob is spawned as a baby. Boolean

Applies to chicken, sheep, rabbit, pig, wolf, cow, mooshroom, and cowctus.

Loot Tags

Listed below are all the tags that are used in loot tables.

Tag Name Description Values and Applicable Situations
item This is the item that is produced if the conditions are right for the item to be dropped. Item Data or String

Must be in all loot tags.

quantity The minimum number of times the item drops (if the conditions are met). Defaults to 1. Int
bonus A random number of extra items can be dropped up to the specified value (if the conditions are met). Defaults to 0.

The calculation of extra items is as expected: floor(random()*(bonus + 1))

Int
lootBonus A random number of extra items can be dropped at max looting enchantment (if the conditions are met) up to the specified value. Defaults to 0.

The calculation of extra items is as follows: floor((random()*.6 + .4)*lootLevel/3*(loot + 1))

Int
chance A success condition

This adds a random chance that the loot will drop. If the condition is not met, the loot will not be dropped.

The procedure is as follows:

  • Generate a random number for the given seed if it doesn't already exists
  • Calculate chance: random(seed)*(1 - lootOffset*lootLevel/3)
  • Succeed condition if chance >= min and chance < max

Using the same seed can allow a loot table to drop one item or another one, but never both.

Object

The chance object is as follows (with default values): {seed:0, min:0, max:1, lootOffset:0}

seed determines which random number to use. min determines the lower bound to succeed the check. max determines the upper bound to succeed the check. lootOffset reduces the range of the random number per level of looting

variant A success condition

Only drops the item if the mob variant matches the killed mob.

String

Only applies to mobs with variants. Accepts "normal", "mooshroom", and "cowctus".

sheared A success condition

Only drops the item if the mob is or is not sheared, depending on the value.

Boolean

Applies to the sheep mob.

isBaby A success condition

Only drops the item if the mob is or is not a baby, depending on the value.

Boolean

Applies to all mobs.

color A success condition

Only drops the item if the color of the object matches, depending on the value.

Color

Only applies to sheep and dog mobs.

onFire A success condition

Only drops the item if object is on fire.

Boolean

Applies to all mobs.

size A success condition

Only drops the item if a mob's size matches the value.

Int

Only applies to magma_cube and slime.


Colors Values

For colored items or blocks, the color is specified using the type data tag.

Type Preview
red
green
blue
brown
cyan
lightblue
lightgreen
magenta
orange
pink
purple
white
yellow
lightgray
gray
black
rainbow

History

Version Date Changes
1.25 May 11, 2013
  • Added data tags to store item properties
1.28 Oct 08, 2016
  • Data tags can be specified when using the /give command
1.29 Sep 27, 2019
  • New item data tags: "canDestroy" and "canPlaceOn"
  • Unbreakable works on armor again
  • Added data tags for blocks, mobs, and mob loot
1.29.1 Oct 05, 2019
  • Fixed being unable to pick up items matching against blank data tags
  • Loot data tag "chance" now applies to drop table
  • Block data tag "powered" renamed to "activated"

See also