Difference between revisions of "Data tags"
m |
m |
||
Line 1: | Line 1: | ||
+ | {{Tocright}} | ||
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. | 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. | ||
Line 35: | Line 36: | ||
!Values and Applicable Items | !Values and Applicable Items | ||
|- | |- | ||
− | + | !<code>type</code> | |
|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. | |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'' | |''String'' | ||
Line 49: | Line 50: | ||
<code>balloon</code>: Color, or "ghast" | <code>balloon</code>: Color, or "ghast" | ||
|- | |- | ||
− | + | !<code>unbreakable</code> | |
|If enabled, and the item is a tool, the item will never lose durability. | |If enabled, and the item is a tool, the item will never lose durability. | ||
|''Boolean'' | |''Boolean'' | ||
Line 55: | Line 56: | ||
Applies to all tools. Value is simply omitted when false. | Applies to all tools. Value is simply omitted when false. | ||
|- | |- | ||
− | + | !<code>enchantments</code> | |
|A list of enchantments applied to the item. | |A list of enchantments applied to the item. | ||
|''Array of Strings'' | |''Array of Strings'' | ||
Line 63: | Line 64: | ||
See [[Enchanting#Commands|enchanting]] for a list of enchantment identifiers. | See [[Enchanting#Commands|enchanting]] for a list of enchantment identifiers. | ||
|- | |- | ||
− | + | !<code>anvilUses</code> | |
|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. | |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'' | |''Integer'' | ||
Line 69: | Line 70: | ||
Applies to all items. | Applies to all items. | ||
|- | |- | ||
− | + | !<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'' | ||
Line 75: | Line 76: | ||
Applies to all items. | Applies to all items. | ||
|- | |- | ||
− | + | !<code>canDestroy</code> | |
|Specifies the [[identifiers|id]] of the block the item can destroy in [[Adventure]] mode. | |Specifies the [[identifiers|id]] of the block the item can destroy in [[Adventure]] mode. | ||
|''String'' or ''Array of Strings'' | |''String'' or ''Array of Strings'' | ||
Line 83: | Line 84: | ||
The special string <code>all</code> inverts the mask. | The special string <code>all</code> inverts the mask. | ||
|- | |- | ||
− | + | !<code>canPlaceOn</code> | |
|Specifies the id of the block which the item can be placed in [[Adventure]] mode. | |Specifies the id of the block which the item can be placed in [[Adventure]] mode. | ||
|''String'' or ''Array of Strings'' | |''String'' or ''Array of Strings'' | ||
Line 91: | Line 92: | ||
The special string <code>all</code> inverts the mask. | The special string <code>all</code> inverts the mask. | ||
|- | |- | ||
− | + | !<code>showParticles</code> | |
|When disabled, this will hide the particles of [[potion effects]] when a [[Potions|potion]] is drank. | |When disabled, this will hide the particles of [[potion effects]] when a [[Potions|potion]] is drank. | ||
|''Boolean'' | |''Boolean'' | ||
Line 97: | Line 98: | ||
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. | |Specifies the category of certain items. | ||
|''String'' | |''String'' | ||
Line 103: | Line 104: | ||
Only applies to <code>potion</code>. Potions with the "splash" category are [[splash potions]]. | Only applies to <code>potion</code>. Potions with the "splash" category are [[splash potions]]. | ||
|- | |- | ||
− | + | !<code>command</code> | |
|Specifies the command run by a [[command book]]. | |Specifies the command run by a [[command book]]. | ||
|''String'' | |''String'' | ||
Line 109: | Line 110: | ||
Only applies to <code>command_book</code>. Command will not be checked for errors upon creation. | Only applies to <code>command_book</code>. Command will not be checked for errors upon creation. | ||
|- | |- | ||
− | + | !<code>uses</code> | |
|Specifies how many times a [[command book]] can be used before it disappears. | |Specifies how many times a [[command book]] can be used before it disappears. | ||
|''Integer'' | |''Integer'' | ||
Line 124: | Line 125: | ||
!Values and Applicable Blocks | !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. | |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'' | |''String'' | ||
Line 135: | Line 136: | ||
|- | |- | ||
− | + | !<code>name</code> | |
|Specifies the display name of a container block (such as a chest), as if it was renamed by an anvil. | |Specifies the display name of a container block (such as a chest), as if it was renamed by an anvil. | ||
|''String'' | |''String'' | ||
Line 142: | Line 143: | ||
|- | |- | ||
− | + | !<code>growth</code> | |
|Specifies the growth stage of a crop. | |Specifies the growth stage of a crop. | ||
|''Integer'' | |''Integer'' | ||
Line 149: | Line 150: | ||
|- | |- | ||
− | + | !<code>text</code> | |
|Defines the writing on a sign. | |Defines the writing on a sign. | ||
|''String'' | |''String'' | ||
Line 156: | Line 157: | ||
|- | |- | ||
− | + | !<code>damage</code> | |
|Specifies the damage state of an anvil. | |Specifies the damage state of an anvil. | ||
|''Integer'' | |''Integer'' | ||
Line 163: | Line 164: | ||
|- | |- | ||
− | + | !<code>items</code> | |
|Defines the items inside of the container. | |Defines the items inside of the container. | ||
|''Item Data'' or ''Array of Item Data'' | |''Item Data'' or ''Array of Item Data'' | ||
Line 174: | Line 175: | ||
|- | |- | ||
− | + | !<code>input</code> | |
|Defines the input item of a block. | |Defines the input item of a block. | ||
|''Item Data'' | |''Item Data'' | ||
Line 185: | Line 186: | ||
|- | |- | ||
− | + | !<code>fuel</code> | |
|Defines the fuel item of a block. | |Defines the fuel item of a block. | ||
|''Item Data'' | |''Item Data'' | ||
Line 194: | Line 195: | ||
|- | |- | ||
− | + | !<code>output</code> | |
|Defines the output item(s) of a block. | |Defines the output item(s) of a block. | ||
|''Item Data'' or ''Array of Item Data'' (for <code>brewing_stand</code>) | |''Item Data'' or ''Array of Item Data'' (for <code>brewing_stand</code>) | ||
Line 203: | Line 204: | ||
|- | |- | ||
− | + | !<code>activated</code> | |
|Defines whether a block is activated. | |Defines whether a block is activated. | ||
|''Boolean'' | |''Boolean'' | ||
Line 209: | Line 210: | ||
Only applies to the switch state of a <code>lever</code> | Only applies to the switch state of a <code>lever</code> | ||
|- | |- | ||
− | + | !<code>facing</code> | |
|Determines the orientation of a block. | |Determines the orientation of a block. | ||
|''String'' | |''String'' | ||
Line 224: | Line 225: | ||
|} | |} | ||
− | |||
=== Mob Tags === | === Mob Tags === | ||
Line 234: | Line 234: | ||
!Values and Applicable Mobs | !Values and Applicable Mobs | ||
|- | |- | ||
− | + | !<code>name</code> | |
|Specifies the name of the mob, as though applied via a [[name tag]]. | |Specifies the name of the mob, as though applied via a [[name tag]]. | ||
|''String'' | |''String'' | ||
Line 241: | Line 241: | ||
|- | |- | ||
− | + | !<code>health</code> | |
|Specifies the current health of the mob. | |Specifies the current health of the mob. | ||
|''Integer'' | |''Integer'' | ||
Line 248: | Line 248: | ||
|- | |- | ||
− | + | !<code>holding</code> | |
|Specifies the item in the mob's hand slot. | |Specifies the item in the mob's hand slot. | ||
|''Item Data'' or ''String'' | |''Item Data'' or ''String'' | ||
Line 255: | Line 255: | ||
|- | |- | ||
− | + | !<code>armor</code> | |
|Specifies the items in the mob's armor slots. | |Specifies the items in the mob's armor slots. | ||
|''Array of Item Data or String, length 4'' | |''Array of Item Data or String, length 4'' | ||
Line 266: | Line 266: | ||
|- | |- | ||
− | + | !<code>defaultDrops</code> | |
|Specifies whether or not the mob will drop their default items upon death. | |Specifies whether or not the mob will drop their default items upon death. | ||
Line 275: | Line 275: | ||
|- | |- | ||
− | + | !<code>drops</code> | |
|Specifies the loot the mob will drop upon death. | |Specifies the loot the mob will drop upon death. | ||
|''Array of Loot Data'' | |''Array of Loot Data'' | ||
Line 286: | Line 286: | ||
|- | |- | ||
− | + | !<code>skin</code> | |
|Specifies the skin ID for <code>spawnskin</code> mobs. | |Specifies the skin ID for <code>spawnskin</code> mobs. | ||
|''Integer'' | |''Integer'' | ||
Line 293: | Line 293: | ||
|- | |- | ||
− | + | !<code>aggro</code> | |
|Specifies the hostility of <code>spawnskin</code> mobs. | |Specifies the hostility of <code>spawnskin</code> mobs. | ||
|''String'' | |''String'' | ||
Line 305: | Line 305: | ||
|- | |- | ||
− | + | !<code>charged</code> | |
|Determines whether or not a creeper is charged. | |Determines whether or not a creeper is charged. | ||
|''Boolean'' | |''Boolean'' | ||
Line 312: | Line 312: | ||
|- | |- | ||
− | + | !<code>baby</code> | |
|Specifies if the mob is spawned as a baby. | |Specifies if the mob is spawned as a baby. | ||
|''Boolean'' | |''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>. | 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>. | ||
− | |||
|} | |} | ||
Line 328: | Line 327: | ||
!Values and Applicable Situations | !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. | |This is the item that is produced if the conditions are right for the item to be dropped. | ||
|''Item Data'' or ''String'' | |''Item Data'' or ''String'' | ||
Must be in all loot tags. | 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. | |The minimum number of times the item drops (if the conditions are met). Defaults to 1. | ||
|''Int'' | |''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. | |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> | The calculation of extra items is as expected: <code>floor(random()*(bonus + 1))</code> | ||
|''Int'' | |''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. | |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*(lootBonus + 1))</code> | The calculation of extra items is as follows: <code>floor((random()*.6 + .4)*lootLevel/3*(lootBonus + 1))</code> | ||
− | |||
|''Int'' | |''Int'' | ||
− | |||
|- | |- | ||
− | + | !<code>chance</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 375: | Line 369: | ||
<code>max</code> determines the upper 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>lootOffset</code> reduces the range of the random number per level of looting | ||
− | |||
|- | |- | ||
− | + | !<code>variant</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 384: | Line 377: | ||
Only applies to mobs with variants. Accepts "normal", "mooshroom", and "cowctus". | Only applies to mobs with variants. Accepts "normal", "mooshroom", and "cowctus". | ||
− | |||
|- | |- | ||
− | + | !<code>sheared</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 393: | Line 385: | ||
Applies to the <code>sheep</code> mob. | Applies to the <code>sheep</code> mob. | ||
− | |||
|- | |- | ||
− | + | !<code>isBaby</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 402: | Line 393: | ||
Applies to all mobs. | Applies to all mobs. | ||
− | |||
|- | |- | ||
− | + | !<code>color</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 411: | Line 401: | ||
Only applies to <code>sheep</code> and <code>dog</code> mobs. | Only applies to <code>sheep</code> and <code>dog</code> mobs. | ||
− | |||
|- | |- | ||
− | + | !<code>onFire</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 420: | Line 409: | ||
Applies to all mobs. | Applies to all mobs. | ||
− | |||
|- | |- | ||
− | + | !<code>size</code> | |
|''A success condition'' | |''A success condition'' | ||
Line 429: | Line 417: | ||
Only applies to <code>magma_cube</code> and <code>slime</code>. | Only applies to <code>magma_cube</code> and <code>slime</code>. | ||
− | |||
|} | |} | ||
Revision as of 18:02, 30 November 2021
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 replaces a block near the player with a chest named "Lemon Chest" full of iron pickaxes with only one use left:
setblock chest ~1 ~-1 replace {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}]}
This command spawns a skin named "Red" that wears a diamond helmet and will attack the player back if hit:
summon spawnskin 1 ~ ~ {skin:67524, aggro:"neutral", armor:["diamond_helmet", {}, {}, {}], name:"Red"}
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
|
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 in Adventure mode. | String or Array of Strings
Applies to any item. The specified IDs must be that of blocks. The special string |
canPlaceOn
|
Specifies the id of the block which the item can be placed in Adventure mode. | String or Array of Strings
Only applies blocks. The specified IDs must be that of blocks. The special string |
showParticles
|
When disabled, this will hide the particles of potion effects when a potion is drank. | Boolean
Only applies to |
category
|
Specifies the category of certain items. | String
Only applies to |
command
|
Specifies the command run by a command book. | String
Only applies to |
uses
|
Specifies how many times a command book can be used before it disappears. | Integer
Only applies to |
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
|
name
|
Specifies the display name of a container block (such as a chest), as if it was renamed by an anvil. | String
Applies to |
growth
|
Specifies the growth stage of a crop. | Integer
Applies to |
text
|
Defines the writing on a sign. | String
Applies only to |
damage
|
Specifies the damage state of an anvil. | Integer
Applies only to |
items
|
Defines the items inside of the container. | Item Data or Array of 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
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
|
output
|
Defines the output item(s) of a block. | Item Data or Array of Item Data (for brewing_stand )
|
activated
|
Defines whether a block is activated. | Boolean
Only applies to the switch state of a |
facing
|
Determines the orientation of a block. | String
Any Any
|
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. |
armor
|
Specifies the items in the mob's armor slots. | Array of Item Data or String, length 4
Applies only to zombies and spawnskins. If String is specified in place of the item data in the array, a single item matching the value's identifier will be given to the mob. An empty The elements of the array correspond to the helmet slot, chestplate slot, leggings slot, and boots slot respectively from first to last. |
defaultDrops
|
Specifies whether or not the mob will drop their default items upon death.
Often used in combination with |
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 |
skin
|
Specifies the skin ID for spawnskin mobs.
|
Integer
Applies only to |
aggro
|
Specifies the hostility of spawnskin mobs.
|
String
Applies only to The valid values are:
|
charged
|
Determines whether or not a creeper is charged. | Boolean
Applies only to |
baby
|
Specifies if the mob is spawned as a baby. | Boolean
Applies to |
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: |
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: |
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:
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):
|
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 |
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 |
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 |
Color 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 |
|
1.28 | Oct 08, 2016 |
|
1.29 | Sep 27, 2019 |
|
1.29.1 | Oct 05, 2019 |
|
1.29.2 | Oct 20, 2019 |
|
1.30 | Nov 13, 2020 |
|