Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Data component format

From SAS Gaming Wiki
(Redirected from Minecraft:Minecraft:food)

Template:ForTemplate:Exclusive

Data components, or simply components, are structured data used to store information and define behavior. Their IDs are Minecraft:namespaced identifiers, and their values can be any data type – see Template:Slink.

When used by Minecraft:items, they are referred as item components or item stack components. They can exist anywhere that an item is stored, such as the player's inventory, container block entities, and Minecraft:structure files. Importantly, not all characteristics of items are covered by data components, and remain as fixed properties associated with the item ID; the behaviour cannot be removed from the item, nor applied to a different item that does not have that behaviour by default. For a reasonably comprehensive list of such properties associated with items in the latest version, see Minecraft:Java Edition hardcoded item properties.

Data components are only partly implemented for Minecraft:block entities. They partially replace the Minecraft:NBT format and allow some block data to be read or copied through predicates and loot functions.

Similarly, entities can interact with data components through predicates and loot functions, however they still strictly use the Minecraft:NBT format and other older internal systems to store their data in memory, not data components.

Template:TOC

Usage

Command format

Data components can be used in the item_stack and item_predicate argument types.

In commands that take an item_stack argument, such as Template:Command, items are represented in the format item_id[component1=value,component2=value], with component being the Minecraft:namespaced ID of a component, and the value being the value of the component written in SNBT format. Components can be removed by prefixing them with an exclamation mark, like item_id[!component3]. Any components that are not specified are implicitly set to the component's default value for that item type. If no components are specified, the square brackets can be removed, leaving just the item ID. See item_stack for details.

In commands that take an item_predicate argument, such as Template:Command and Template:Command, item predicates are represented in the format item_type[list of tests], with each test either checking if a component exists with any value, checking for an exact component value match, or checking for a Minecraft:data component predicate. See item_predicate for details.

Item format

Template:For

Every item type (item ID) has a set of default data components. Item stacks must specify an item ID, which implicitly sets these default components, but they may be overridden by that individual item stack. Default components are not saved on individual item stacks.

When saved in the Minecraft:NBT format, items are written as a compound with the following tags:

  • Template:Nbt The root tag. <section begin="item format" /><section begin="item format nocount" />

In containers that do not use the data component format (such as container blocks and entity inventories), an additional Template:Nbt tag is used to specify the slot the item is in e.g. {Slot:0b,id:"stone"}. This is not a part of the item stack format so is not present anywhere else where individual items are stored (such as single-slot containers, unstructured lists of items, etc.). In the data component format, slot numbers and item stacks are stored as separate fields e.g. {slot:0,item:{id:"stone"}}.

Block entity format

Template:Main Block entities are stored in the Minecraft:NBT format. While they still use NBT tags for their individual properties, any non-default data components that exist on the item used to place the block will be saved.

Some NBT data on block entities are treated as data components when transferring data between items and blocks. For example, the Items field in a chest is interpreted as the minecraft:container component, despite being labeled and structured differently.

{{#lst:Block entity format|nbt format}}

For example, if a chest was given to a player with the components minecraft:custom_data={foo:1} and minecraft:container=[{slot:0,item:{id:"stone"}}]], then placed the block on the ground, the block will be saved (omitting some fields) as:

{id:"minecraft:chest", Items:[{count:1,id:"minecraft:stone",Slot:0b}], components:{"minecraft:custom_data":{foo:1}}}

with minecraft:container saved as the Items tag, and minecraft:custom_data separated as it is not used by chest block entities.

List of components

Template:DCLTemplate:Columns-list

attack_range

    • Template:Nbt: Determines the Minecraft:attack range and Minecraft:hitbox margin of a weapon.
      • Template:Nbt: The minimum distance in blocks from the attacker to the target to be considered valid. Defaults to 0.0, valid from 0.0 to 64.0.
      • Template:Nbt: The maximum distance in blocks from the attacker to the target to be considered valid. Defaults to 3.0, valid from 0.0 to 64.0.
      • Template:Nbt: The minimum distance in blocks from the attacker to the target to be considered valid in Minecraft:Creative mode. Defaults to 0.0, valid from 0.0 to 64.0.
      • Template:Nbt: The maximum distance in blocks from the attacker to the target to be considered valid in Creative mode. Defaults to 5.0, valid from 0.0 to 64.0.
      • Template:Nbt: The margin applied to the target bounding box when checking for valid hitbox collision. Defaults to 0.3, valid from 0.0 to 1.0.
      • Template:Nbt: The multiplier applied to Template:Cd and Template:Cd when checking for valid distance if item is used by a mob. Defaults to 1.0, valid from 0.0 to 2.0.

Example: Template:Cmd

  • Gives a diamond that has an attack range of 5 blocks.

attribute_modifiers

Example: Template:Command

  • Gives a stick that causes the player to grow 4x when holding it.

Example: Template:Command

  • Gives a black banner with a red triangle and white cross pattern.

base_color

Example: Template:Command

  • Gives a lime shield.

bees

Example: Template:Command

  • Gives a bee nest containing a single bee named Maya, which exits the bee nest in 3 seconds.

block_entity_data

Example: Template:Command

block_state

Example: Template:Command

  • Gives a bamboo slab that is always placed in the top half of the block.

blocks_attacks

Example: Template:Command

  • Gives a diamond sword that can block half of the damage from mob attacks, arrows, and explosions, cannot be disabled by a disabling attack, and plays the anvil place sound upon successful blocking.

break_sound

Example: Template:Command

  • Gives a diamond sword that when runs out of durability, it plays the wolf armor break sound.

bucket_entity_data

Other tags such as the entity's name or variant are stored as separate item components such as Template:Cd and Template:Cd.

Example: Template:Command

  • Gives a bucket of axolotl that has 3 health, the Wild type, and is named "Bob".

bundle_contents

Example: Template:Command

  • Gives a bundle containing exactly 2 diamonds.

can_break

When present, the player holding the item can break the specified blocks in Minecraft:Adventure mode.

Example: Template:Command

  • Gives a netherite pickaxe that can only mine some ores, as well as black concrete.

can_place_on

When present, the player holding the item can place the held block item on any sides of the specified blocks in Minecraft:Adventure mode.

Example: Template:Command

  • Gives a target block that can only be placed on sandstone.

charged_projectiles

Example: Template:Command

  • Gives a crossbow that is already charged with a spectral arrow.

Note: Adding an invalid projectile or item id charges an arrow that, when collected, grants the wrong item. Ex: wind_charge causes it to fire an arrow that grants a wind charge when collected.

consumable

Template:DCL If present, the item can be consumed. Its options can also be modified.

  • If the item already has an existing right-click functionality (like placing a block), it keeps that functionality.
  • If the Template:DCL, Template:DCL, Template:DCL or Template:DCL components are also present on this item, consuming it applies the stats and effects of those components.
  • If the Template:DCL component are also present on this item, Minecraft:foxes consider the item as consumable food.

Example: Template:Command

  • Gives a gold ingot that can be eaten in 3 seconds and upon consuming, clears all effects.

container

Example: Template:Command

  • Gives a barrel with an apple in the first slot.

container_loot

Example: Template:Command

  • Gives a chest that contains the desert pyramid loot when opened.

custom_data

Example: Template:Command

  • Gives an iron sword with custom data {foo:1}.

custom_model_data

Example:

Template:Command
  • Gives a bone with custom model data. The colors list shows three possible representations of the same violet color.

custom_name

Used to specify an item, block, or entity's custom name. This component can be added, changed, or removed by any player with the item who has access to an anvil.

    • Template:NbtTemplate:NbtTemplate:Nbt minecraft:custom_name: The player-assigned name of this item, block, or entity, typically assigned with an Minecraft:anvil or a Minecraft:name tag. See Minecraft:Text component format.
    • If present on an item, this component has highest priority to display as the item's name, and appears italic unless overridden by the text component format.
    • If present on an entity, it will replace the entity's name tag, will show the name tag to players when they hover over the entity (unless invisible), and will appear as that entity's name in commands and chat messages.
    • If present on a block with a GUI (such as a container), this replaces the name at the top of the GUI.
    • If present on a Minecraft:command block, this replaces the execution context name when the command is ran.

Example:

Template:Command
  • Gives a stick named "Magic Wand" in light purple non-italicized text.

damage

Example: Template:Command

  • Gives a diamond axe with 500 points of damage.

damage_resistant

Example: Template:Command

  • Gives a cake that is immune to all types of fire damage.

damage_type

Example: Template:Command

  • Gives a diamond sword that deals "campfire" type damage.

death_protection

Example: Template:Command

  • Gives a nether star that protects the holder from death and removes all status effects from the holder.

debug_stick_state

Example: Template:Command

dye

Example: Template:Command

  • Gives a blue dye item that acts like a red dye.

dyed_color

  • Template:Nbt: Parent tag.
    • Template:Nbt: The RGB color of the tint applied to a dyed item, typically as a result of combining the item with dyes in a Template:Cd type crafting recipe. More generally, this component is used as the Template:Cd color provider in Minecraft:item model definitions (so only item models that explicitly use this color provider will be tinted). If present on an item, gray text is added to the tooltip showing either an italic "Dyed" when Minecraft:advanced tooltips is off, or a non-italic "Color: #Template:Cd"<ref group="note">The hexadecimal number is always at least 6 digits (with leading zeroes if needed), with additional digits if the alpha channel is included, despite the alpha channel having no effect on the tint color.</ref> instead when Minecraft:advanced tooltips is on. The color is stored as an integer which packs the color's red, green and blue channels using this formula:
      (Template:Color << 16) + (Template:Color << 8) + Template:Color<ref group="note">For positive values larger than 0x00FFFFFF, the most significant byte encodes the alpha channel (opacity), however this is effectively ignored when providing the tint color to the item model, as the tint does not affect opacity.</ref> Template:Calculator
    • Template:Nbt: An alternative format. A list of 3 floats, ranging from 0.0 to 1.0 (inclusive)<ref group="note">Float values outside of this range are accepted, but clamped from 0 to 255 by modulo 256 after being multiplied by 255. For example, -1.0 is equivalent to 0.00392156862 (or 1/255).</ref>, corresponding to the red, green and blue channels of the color. This format is automatically packed into the integer format by multiplying each float by 255, converting them to unsigned bytes (equivalent to taking the floor and then applying modulo 256), then using the formula -16777216 + (Template:Color << 16) + (Template:Color << 8) + Template:Color due to the alpha channel being implicitly set to 255, resulting in a negative integer.<ref group="note">This can result in an item that is not normally obtainable and it affects the hexadecimal code that is shown in the (advanced) tooltip. For example Template:Cd shows "#000000" but Template:Cd shows "#FF000000" despite them both representing the same pure black RGB color.</ref>.

Example: Template:Command

or: Template:Command

or: Template:Command

  • Gives a blueish-green leather helmet.

enchantable

Example: Template:Command

  • Gives a pair of elytra that can be enchanted in an enchanting table with an enchantability of 15.

enchantment_glint_override

Example: Template:Command

  • Gives an experience bottle without the visual enchantment glint, which is otherwise applied by default.

enchantments

Example: Template:Command

  • Gives a wooden sword with sharpness III and knockback II.

Note: This component adds active enchantments and should not be confused with the Template:DCL component, which is used to add inactive enchantments, such as with enchanted books.

To illustrate the difference, hitting an entity with an Template:Cd would knock any entity hit per knockback II while hitting an entity with an Template:Cd would not.

Furthermore the latter would be able to add knockback II to an enchantable item in an anvil, while the former would not.

entity_data

Example: Template:Command

  • Gives an armor stand that is small when placed down.

equippable

Example 1: Template:Command

  • Gives a glass block that can be equipped in the helmet slot.

Example 2: Template:Command

  • Gives a pair of leather pants that appear as diamond leggings when worn.

firework_explosion

fireworks

food

If present and the Template:DCL component are also present on this item, Minecraft:foxes consider the item as consumable food.

Example 1: Template:Command

  • Gives a melon slice that can be eaten at any time and restores 3 food points and 1 saturation.

Example 2: Template:Command

  • Gives a sponge that can be eaten at any time, takes 2.4 seconds to consume, and restores 5 food points and 5 saturation.

glider

    • Template:Nbt: If present, this item allows living entities to glide (as with Minecraft:elytra) when equipped. If the item is damageable, it will only allow entities to glide if it has Template:DCL < Template:DCL − 1. Every second while an entity is gliding, the game will select a random equipped glider item that isn't too damaged to function and try to apply one point of durability damage.

Example: Template:Command

  • Gives a nether star that can be equipped in the head slot, and if is placed on the head, it allows the player to glide.

instrument

    • Template:NbtTemplate:Nbt: Template:Json ref. If present on an item, the description of the instrument is shown in the item's tooltip as gray text.

      There are actually two unique states of this component that both register in usage as the minecraft:ponder_goat_horn instrument ID, but they do not stack with each other, only one of them matches a component comparison for that ID, and only one of them gets serialised while the other does not.

Example 1: Template:Command

Example 2: Template:Command

  • Gives a goat horn that plays the entity.creeper.primed sound.

intangible_projectile

Example: Template:Command

item_model

Example: Template:Command

  • Gives a netherite sword that looks like a diamond sword.

item_name

Example: Template:Command

  • Gives a diamond that is named "Dirt".

jukebox_playable

Example: Template:Command

  • Gives a diamond that plays Pigstep when inserted into a jukebox

kinetic_weapon

    • Template:Nbt: Enables a charge-type attack when using the item where, while being used, the damage is dealt along a ray every tick based on the relative speed of the entities

</ref> Defaults to 1.0.

Example: Template:Command

  • Gives an amethyst shard which can perform a charge attack after a 1-second delay. The attack can damage entities for 3 seconds, knock them back for the first 2 seconds and dismount them for the first second. Hitting a target with the attack plays an amethyst sound.

lock

Example 1: Template:Command

  • Gives a chest that is locked, opening only if the player is holding an item with the same model as a Diamond.

Example 2: Template:Command

  • Gives a furnace that opens only if the player is holding an item with the custom name "Furnace Key".

Example 3: Template:Command

lodestone_tracker

Example: Template:Command

  • Gives a compass that points toward a lodestone that is located in the Overworld at x=1,y=2,z=3

lore

Example 1: Template:Command

  • Gives a stick with lore in its tooltip.

Example 2: Template:Command

  • Gives a diamond that has lore in its tooltip. The color of the lore is gold, and its italics have been removed.

Example 3: Template:Command

  • Gives an emerald that has 2 lines of lore in its tooltip. The first line has a golden color, and the second has a yellow color. Both lines have had their italics removed.

map_color

Example: Template:Command

  • Gives a filled map with red markings on item texture.

Template:Calculator

map_decorations

map_id

max_damage

Example: Template:Command

  • Gives a diamond pickaxe that can only be used 4 times before breaking.

max_stack_size

Example: Template:Command

  • Gives a stack of 5 acacia boats all in a single slot.

minimum_attack_charge

Example: Template:Command

  • Gives a diamond sword that can only attack once the attack indicator is at least half full.

note_block_sound

Example: Template:Command

  • Gives a Player Head of the minecraftWiki. If placed on a Note Block, the Note Block plays the "Item Pickup" sound every time it's activated.

ominous_bottle_amplifier

piercing_weapon

Example: Template:Command

  • Gives a blaze rod which whose melee attack pierces targets, dealing 1 damage to each, with fiery and explosive sounds accompanying the attacks.

pot_decorations

Example: Template:Command

potion_contents

Template:Calculator

potion_duration_scale

Example: Template:Command

  • Gives a Potion of Swiftness that has its default time doubled from 3 Minutes to 6 Minutes.

profile

Example: Template:Command

  • Gives a player head of MinecraftWiki.

Template:Calculator

provides_banner_patterns

Example: Template:Command

  • Gives a diamond that can provide the globe banner pattern to a banner.

provides_trim_material

rarity

Example: Template:Command

  • Gives an iron sword with a light purple name.

recipes

Example: Template:Command

  • Gives a knowledge book that, when used, gives the player the recipes listed inside the component.

repair_cost

repairable

    • Template:Nbt: Allows the item to be repaired, if damageable, in an anvil using the specified ingredient. Also repairs equipped items in the body slot of a tamed wolf.

Example: Template:Command

  • Gives a diamond sword that can be repaired with sticks in an anvil.

stored_enchantments

    • Template:Nbt: Contains a map of inactive Minecraft:enchantments and their levels. Adding this component to any item other than an Minecraft:enchanted book does nothing except add text to the item's tooltip. If this component is removed from an enchanted book, the item can no longer be combined with other enchanted books. If present on an item, the enchantments are listed in the item's tooltip. The order of the enchantments in the tooltip is defined by the #minecraft:tooltip_order enchantment tag.

sulfur_cube_content

Template:In development

suspicious_stew_effects

swing_animation

tool

Example: Template:Command

  • Gives an oak fence that has the properties of a pickaxe.

tooltip_display

Example 1: Template:Command

  • Gives a diamond sword that is enchanted with Sharpness I, but doesn't show the enchantments in the tooltip.

Example 2: Template:Command

  • Gives a diamond sword that when hovered, it shows no tooltip at all.

tooltip_style

trim

Example: Template:Command

unbreakable

  • Template:Nbt: Parent tag.
    • Template:Nbt: If present on an item, the item cannot lose durability, its durability bar is hidden, and a blue "Unbreakable" text is added to its tooltip.

Example: /give @p wooden_spear[unbreakable={}]

use_cooldown

    • Template:Nbt: If present, this item applies a Minecraft:use cooldown to all items of the same type when it has been used.
      • Template:Nbt: The use cooldown duration in seconds.
      • Template:Nbt: The unique Minecraft:resource location to identify this cooldown group. If present, the item is included in a use cooldown group and no longer shares cooldowns with its base item type, but instead with any other items that are part of the same use cooldown group. Optional.

Example: Template:Command

  • Gives an ender pearl that has a 10 second cooldown after being used, and also applies that cooldown to any item that shares its 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_effects

use_remainder

Example 1: Template:Command

  • Gives a splash potion, which after being thrown, leaves gunpowder.

Example 2: Template:Command

  • Gives a cooked chicken, which after being used, turns into 2 bones named "Chicken Bone".

weapon

If present, the item acts as a weapon. For attack damage see the Template:DCL component.

Example 1: Template:Command

  • Gives a stick that has 10 durability, and loses 1 durability for each attack performed.

Example 2: Template:Command

  • Gives an iron sword that disables shields for 5 seconds when used on them, but loses 10 durability for each attack performed.

writable_book_content

written_book_content

Entity variant components

Template:Work in progress Entity variant components are a group of components that are present in items like spawn eggs, mob buckets, paintings, item frames, etc. These components modify some of the properties of the entity stored within those items.

Here is a list of all entity variant components:

Template:Columns-list

axolotl/variant

Example: Template:Command

  • Gives a axolotl spawn egg that spawns a blue axolotl.

cat/collar

Example: Template:Command

  • Gives a cat spawn egg that spawns a cat with a blue collar (once tamed).

cat/variant

Example: Template:Cmd

  • Gives a cat spawn egg that spawns a Jellie (gray and white) cat.

chicken/variant

Example 1: Template:Cmd

  • Gives a chicken spawn egg that spawns a cold chicken.

Example 2: Template:Cmd

  • Gives an egg that has a chance to hatch a cold chicken.

cow/variant

Example: Template:Cmd

  • Gives a cow spawn egg that spawns a cold cow.

fox/variant

Example: Template:Cmd

  • Gives a fox spawn egg that spawns a snow fox.

frog/variant

Example: Template:Cmd

  • Gives a frog spawn egg that spawns a cold frog.

horse/variant

Example: Template:Cmd

  • Gives a horse spawn egg that spawns a chestnut horse.

llama/variant

Example: Template:Cmd

  • Gives a llama spawn egg that spawns a gray llama.

mooshroom/variant

Example: Template:Cmd

  • Gives a mooshroom spawn egg that spawns a brown mooshroom.

painting/variant

Example: Template:Cmd

  • Gives a painting that places the "Paradisträd" painting.

parrot/variant

Example: Template:Cmd

  • Gives a parrot spawn egg that spawns a blue parrot.

pig/variant

Example: Template:Cmd

  • Gives a pig spawn egg that spawns a warm pig.

rabbit/variant

Example: Template:Cmd

  • Gives a rabbit spawn egg that spawns an evil rabbit.

salmon/size

Example: Template:Cmd

  • Gives a salmon spawn egg that spawns a large salmon.

sheep/color

Example: Template:Cmd

  • Gives a sheep spawn egg that spawns a sheep with blue wool.

shulker/color

Example: Template:Cmd

  • Gives a shulker spawn egg that spawns a red shulker.

tropical_fish/base_color

tropical_fish/pattern

tropical_fish/pattern_color

Example: Template:Cmd

  • Gives a tropical fish spawn egg that spawns a red-blue snooper tropical fish.

villager/variant

Example: Template:Cmd

  • Gives a villager spawn egg that spawns a desert villager.

wolf/collar

Example: Template:Cmd

  • Gives a wolf spawn egg that spawns a wolf with a blue collar (when tamed).

wolf/sound_variant

Example: Template:Cmd

  • Gives a wolf spawn egg that spawns a cute wolf.

wolf/variant

Example: Template:Cmd

  • Gives a wolf spawn egg that spawns a rusty wolf.

Non-encoded components

These data components exist and are used by the game internally, but are not encoded on items. Therefore, they cannot be used in commands, nor seen with Template:Command.

additional_trade_cost

creative_slot_lock

map_post_processing

Exclusive to joke versions

The following components were added and used in April Fools' Day joke snapshots.

Minecraft:24w14potato

Template:Collapse

clicks

contacts_messages

explicit_foil

fletching

heat

hovered

lubrication

potato_bane

resin

secret_message

snek

undercover_id

views

xp

Template:Collapse

Minecraft:25w14craftmine

Template:Collapse

dimension_id

exchange_value

  • Template:Nbt: Parent tag.
    • Template:Nbt: The value of the item, which is used to determine how much experience the player gains from it when exiting a mine.

instant_room

mine_active

mine_completed

  • Template:Nbt: Parent tag.
    • Template:Nbt: Whether the mine this mine item refers to was completed. Determines the color of the glint on the item (green if completed, red if failed).

mob_trophy/type

sky

special_mine

trophy/type

world_effect_uhint

world_effect_unlock

world_modifiers

Template:Collapse

Minecraft:26w14a

Template:Collapse

follow

Template:Collapse

History

Template:Info needed section Template:HistoryTable

Notes

Template:Notelist

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Gegenstandsdaten Minecraft:fr:Format de composant de données Minecraft:ja:データコンポーネント Minecraft:ko:데이터 구성 요소 형식 Minecraft:pt:Formato de componente de dado Minecraft:uk:Формат компонента даних Minecraft:zh:数据组件

Contents