{{About|the new format introduced in [[Java Edition 1.20.5]]|the legacy format|Item format|the format of item components in Bedrock Edition|Item components}}
{{redirect|Component|the text format|Raw JSON text format}}
{{exclusive|java}}
{{TOC|right}}
'''Data components''', or simply '''components''', are structured data used to define and store various properties. They are used on [[item]]s, where they are referred as '''item components''' or '''item stack components''', and [[block entities]], partially replacing [[NBT format]].
Data components are used in various places, including the [[Player.dat format|player's inventory]], container [[Chunk format#Block entity format|block entities]] and [[structure file]]s.
Data components are [[Resource location|namespaced identifiers]], and can be of different data types, [[#List of components|listed here]].
== Usage ==
=== Command format ===
Data component can be used in the [[Argument types#minecraft:item_stack|item_stack]] and [[Argument types#minecraft:item_predicate|item_predicate]] argument types.
In commands that take an item_stack argument, such as {{cmd|give}}, items are represented in the format ''item_id''[''component1''=''value'',''component2''=''value'']
, with ''component'' being the [[namespaced ID]], the namespace defaulting to minecraft
, as usual, and the ''value'' being the value of the component in [[NBT format#SNBT format|SNBT format]]. Components can be removed by prefixing them with an exclamation mark, like item_id[!''component3'']
. If no components are specified, the square brackets can be removed, leaving just the item ID. See [[Argument types#minecraft:item_stack|item_stack]] for details.
In commands that take an item_predicate argument, such as {{cmd|clear}}, items are represented in the format ''item_type''[''tests'']
, with ''tests'' can be tests of data components or an [[item sub-predicate]]. See [[Argument types#minecraft:item_predicate|item_predicate]] for details.
=== Item format ===
Items are stored in the [[NBT format]]. Sometimes a {{nbt|byte|Slot}} tag is used to specify the slot the item is in, such as with chests; other times there is no {{nbt|byte|Slot}} tag, such as with dropped items.
Item types hold a set of default components on an item, that individual item stacks can override. Default components are not saved on individual item stacks.
{foo:1}
.
=== custom_model_data ===
{{wip|section=1|Explain more how it works}}
west
and the [[candle]] block state property set to lit
.
=== death_protection ===
''Dyed''
in the tooltip.
{{Calculator|decimalColor}}
=== enchantable ===
cooldown_group
.
** If other items in the inventory share the same cooldown_group
, but have different seconds
, then using that item applies the seconds
of ''itself'' to all other items in the inventory, rather than each item applying their own seconds
to themselves.
* Items can have their cooldowns disabled completely by removing the component with [!use_cooldown]
.
=== use_remainder ===
{...}
item format has been removed, and can no longer be used as a shortcut for {{cd|custom_data}} component.}}
|{{HistoryLine|||dev=24w13a|Added {{cd|d=and|item_name|ominous_bottle_amplifier}} components.
|Components with non-default values on block items are now stored on block entities when placed.}}
|{{HistoryLine|||dev=24w14a|Renamed {{nbt|string|text}} to {{nbt|string|raw}} in {{cd|d=and|writable_book_content|written_book_content}} components.}}
|{{HistoryLine|||dev=Pre-Release 1|Renamed {{nbt|float|saturation_modifier}} to {{nbt|float|saturation}} in {{cd|food}} component.
|{{cd|d=and|max_damage|max_stack_size}} components can no longer be put together.}}
|{{HistoryLine||1.21|dev=24w19a|{{cd|custom_data}} component can now be defined as a SNBT string.
|Added {{nbt|compound|using_converts_to}} in {{cd|food}} component.}}
|{{HistoryLine|||dev=24w21a|Added {{cd|jukebox_playable}} component.
|Changed {{cd|attribute_modifiers}} component: removed {{nbt|string|name}} and {{nbt|int-array|uuid}} fields, added {{nbt|string|id}} field.}}
|{{HistoryLine||1.21.2|dev=24w33a|Added repairable
and enchantable
components.
|The title specified in the written_book_content
component is now prioritized over custom_name
and item_name
for any item with a non-empty title in this component.}}
|{{HistoryLine|||dev=24w34a|Added consumable
, use_cooldown
and use_remainder
components.
|The food
component has been changed to become a data container which only holds the food stats applied when the item is consumed. The component no longer gives the item the ability to be consumed. Removed the {{nbt|float|eat_seconds}}, {{nbt|compound|using_converts_to}} and {{nbt|list|effects}} fields from food
.}}
|{{HistoryLine|||dev=24w36a|Added equippable
, item_model
, glider
and tooltip_style
components.
|The item_name
component is now always present on every item.}}
|{{HistoryLine|||dev=24w37a|Added death_protection
component.
|Renamed fire_resistant
component to damage_resistant
, and added {{nbt|string|types}} field.
|The name provided by the item_name
component now always has the lowest priority.
|Added {{nbt|string|custom_name}} in potion_contents
component.
|Added {{nbt|boolean|swappable}} and {{nbt|boolean|damage_on_hurt}} in equippable
component.}}
|{{HistoryLine|||dev=Pre-Release 1|Added {{nbt|string|camera_overlay}} in equippable
component.}}
|{{HistoryLine||1.21.4|dev=24w45a|{{cd|minecraft:custom_model_data}} now has more fields to accomodate new uses by various model property getters: {{cd|floats}}, {{cd|flags}}, {{cd|strings}} and {{cd|colors}}.}}
}}
== References ==
{{reflist}}
== Navigation ==
{{Navbox Java Edition technical|general}}
[[Category:Development]]
[[de:Gegenstandsdaten]]
[[fr:Format de composant de données]]
[[ja:アイテムフォーマット]]
[[pt:Formato de componente de dado]]
[[uk:Формат компонента даних]]
[[zh:物品堆叠组件]]