Skip to content

Items - Components Module

anvil.api.items.components

ItemAllowOffHand

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines whether an item can be placed in the off-hand slot of the inventory.

Parameters:

Name Type Description Default
value bool

Whether the item can be placed in the off-hand slot.

required

__iter__()

Iterates over the component's fields.

ItemBlockPlacer

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(block, replace_block_item=False)

Sets the item as a Planter item component for blocks. Planter items are items that can be planted into another block.

Parameters:

Name Type Description Default
block str

Set the placement block name for the planter item.

required
use_on str

List of block descriptors that contain blocks that this item can be used on. If left empty, all blocks will be allowed.

required

__iter__()

Iterates over the component's fields.

use_on(*blocks)

List of block descriptors that contain blocks that this item can be used on.

ItemBundleInteraction

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(num_viewable_slots=12)

Specifies the number of slots in the bundle viewable by the player.

Parameters:

Name Type Description Default
num_viewable_slots int

The maximum number of slots in the bundle viewable by the player. Can be from 1 to 64. Default is 12. Value must be >= 1 and <= 64.

12

__iter__()

Iterates over the component's fields.

ItemCanDestroyInCreative

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines if an item will break blocks in Creative Mode while swinging.

Parameters:

Name Type Description Default
value bool

If an item will break blocks in Creative Mode while swinging.

required

__iter__()

Iterates over the component's fields.

ItemCooldown

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(category, duration)

Sets an items "Cool down" time. After using an item, it becomes unusable for the duration specified by the 'duration' setting of this component.

Parameters:

Name Type Description Default
category str

The type of cool down for this item.

required
duration float

The duration of time (in Seconds) items with a matching category will spend cooling down before becoming usable again.

required

__iter__()

Iterates over the component's fields.

ItemCustomComponents

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(*components)

Registers custom components for this item.

Parameters:

Name Type Description Default
components str

The components to register, if the namespace is not provided, the project namespace will be used.

()

__iter__()

Iterates over the component's fields.

ItemDamage

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines how much extra damage an item does on attack.

Parameters:

Name Type Description Default
value bool

How much extra damage the item does on attack. Note that this must be a positive value.

required

__iter__()

Iterates over the component's fields.

ItemDigger

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(*destroy_speeds)

Sets the item as a "Digger" item. Component put on items that dig.

Parameters:

Name Type Description Default
destroy_speeds str

Destroy speed per block.

()

__iter__()

Iterates over the component's fields.

use_efficiency(use_efficiency=False)

Toggles if the item will be used efficiently.

ItemDisplayName

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(display_name, localize=True)

Sets the item display name within Minecraft: Bedrock Edition. This component may also be used to pull from the localization file by referencing a key from it.

Parameters:

Name Type Description Default
display_name str

Set the display name for an item.

required
localize bool

Whether to use the name with a localization file or not. Defaults to True.

True

__iter__()

Iterates over the component's fields.

ItemDurability

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(max_durability, damage_chance=100)

Sets how much damage the item can take before breaking, and allows the item to be combined at an anvil, grindstone, or crafting table.

Parameters:

Name Type Description Default
max_durability int

Max durability is the amount of damage that this item can take before breaking. The minimum value for this parameter is 0.

required
damage_chance int

Damage chance is the percentage chance of this item losing durability. Default is set at 100 to 100.. Defaults to 100.

100

__iter__()

Iterates over the component's fields.

ItemEnchantable

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(slot, value)

Determines what enchantments can be applied to the item. Not all enchantments will have an effect on all item components.

Parameters:

Name Type Description Default
type str

What enchantments can be applied (ex. Using bow would allow this item to be enchanted as if it were a bow).

required
value int

The value of the enchantment (minimum of 0).

required

__iter__()

Iterates over the component's fields.

ItemEntityPlacer

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(entity)

Allows an item to place entities into the world. Additionally, the component allows the item to set the spawn type of a monster spawner.

Parameters:

Name Type Description Default
entity str

The entity to be placed in the world.

required

__iter__()

Iterates over the component's fields.

dispense_on(*blocks)

List of block descriptors that contain blocks that this item can be dispensed on.

use_on(*blocks)

List of block descriptors that contain blocks that this item can be used on.

ItemFireResistant

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value=True)

Determines whether the item is immune to burning when dropped in fire or lava.

Parameters:

Name Type Description Default
value bool

Determines whether the item is immune to burning when dropped in fire or lava. Defaults to True.

True

__iter__()

Iterates over the component's fields.

ItemFood

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(can_always_eat=False, nutrition=0, saturation_modifier=0, using_converts_to=None)

Sets the item as a food component, allowing it to be edible to the player.

Parameters:

Name Type Description Default
can_always_eat bool

If true you can always eat this item (even when not hungry).

False
nutrition int

The value that is added to the actor's nutrition when the item is used. Defaults to 0.

0
saturation_modifier float

Saturation Modifier is used in this formula: (nutrition saturation_modifier 2) when applying the saturation buff. Defaults to 0.

0
using_converts_to str

Saturation Modifier is used in this formula: (nutrition saturation_modifier 2) when applying the saturation buff. Defaults to None.

None

__iter__()

Iterates over the component's fields.

effects(effect, chance, duration, amplifier)

DEPRECATED

Sets the effects of the food item.

Parameters:

Name Type Description Default
effect Effects

The effect to apply.

required
chance float

The chance of the effect being applied.

required
duration Seconds

The duration of the effect.

required
amplifier int

The amplifier of the effect.

required

ItemFuel

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(duration)

Allows this item to be used as fuel in a furnace to 'cook' other items.

Parameters:

Name Type Description Default
duration float

How long in seconds will this fuel cook items for. Minimum value: 0.05.

required

__iter__()

Iterates over the component's fields.

ItemGlint

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines whether the item has the enchanted glint render effect on it.

Parameters:

Name Type Description Default
value bool

Whether the item has the enchanted glint render effect.

required

__iter__()

Iterates over the component's fields.

ItemHandEquipped

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines if an item is rendered like a tool while in-hand.

Parameters:

Name Type Description Default
value bool

Determines if the item is rendered like a tool in-hand.

required

__iter__()

Iterates over the component's fields.

ItemHoverTextColor

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(color)

Determines the color of the item name when hovering over it.

Parameters:

Name Type Description Default
value bool

The color of the item name when hovering over it.

required

__iter__()

Iterates over the component's fields.

ItemIcon

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(texture)

Sets the icon item component. Determines the icon to represent the item in the UI and elsewhere.

Parameters:

Name Type Description Default
texture str

The item texture name to be used.

required

__iter__()

Iterates over the component's fields.

ItemInteractButton

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value=True)

Is a boolean or string that determines if the interact button is shown in touch controls, and what text is displayed on the button. When set to 'true', the default 'Use Item' text will be used.

Parameters:

Name Type Description Default
value bool | str

Determines if the interact button is shown in touch controls, and what text is displayed on the button. Defaults to True.

True

__iter__()

Iterates over the component's fields.

ItemLiquidClipped

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines whether an item interacts with liquid blocks on use.

Parameters:

Name Type Description Default
value bool

Whether an item interacts with liquid blocks on use.

required

__iter__()

Iterates over the component's fields.

ItemMaxStackSize

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(stack_size)

Determines how many of an item can be stacked together.

Parameters:

Name Type Description Default
stack_size int

How many of an item that can be stacked together.

required

__iter__()

Iterates over the component's fields.

ItemProjectile

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(projectile_entity, minimum_critical_power)

Compels the item to shoot, similarly to an arrow. Items with minecraft:projectile can be shot from dispensers or used as ammunition for items with the minecraft:shooter item component. Additionally, this component sets the entity that is spawned for items that also contain the minecraft:throwable component.

Parameters:

Name Type Description Default
projectile_entity Identifier

The entity to be fired as a projectile.

required
minimum_critical_power int

Defines the time a projectile needs to charge in order to critically hit.

required

__iter__()

Iterates over the component's fields.

ItemRecord

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(sound_event, duration, comparator_signal=1)

Used by record items to play music.

Parameters:

Name Type Description Default
sound_event str

Set the placement block name for the planter item.

required
duration float

Duration of sound event in Seconds float value.

required
comparator_signal int

Signal strength for comparator blocks to use from 1 - 13.

1

__iter__()

Iterates over the component's fields.

ItemRepairable

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(on_repaired=None)

Defines the items that can be used to repair a defined item, and the amount of durability each item restores upon repair. Each entry needs to define a list of strings for 'items' that can be used for the repair and an optional 'repair_amount' for how much durability is repaired.

Parameters:

Name Type Description Default
on_repaired str

Event that is called when this item has been repaired.

None

__iter__()

Iterates over the component's fields.

add_items(repair_amount, *repair_items)

Parameters:

Name Type Description Default
repair_amount int

How much durability is repaired.

required
repair_items str

List of repair item entries.

()

ItemShooter

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(charge_on_draw=False, max_draw_duration=0.0, scale_power_by_draw_duration=False)

Sets the shooter item component.

Parameters:

Name Type Description Default
charge_on_draw bool

Sets if the item is charged when drawn (Like crossbows). Defaults to False.

False
max_draw_duration float

How long can it be drawn before it will release automatically. Defaults to 0.0.

0.0
scale_power_by_draw_duration bool

Scale the power by draw duration? When true, the longer you hold, the more power it will have when released.. Defaults to False.

False

__iter__()

Iterates over the component's fields.

ItemShouldDespawn

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines if an item should despawn while floating in the world.

Parameters:

Name Type Description Default
value bool

Sets whether the item should eventually despawn while floating in the world.

required

__iter__()

Iterates over the component's fields.

ItemStackedByData

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines if the same item with different aux values can stack. Additionally, this component defines whether the item actors can merge while floating in the world.

Parameters:

Name Type Description Default
value bool

Sets whether the same item with different aux values can stack and merge while floating in the world.

required

__iter__()

Iterates over the component's fields.

ItemStorageItem

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(allow_nested_storage_items=True, max_slots=64)

Enables an item to store data of the dynamic container associated with it. A dynamic container is a container for storing items that is linked to an item instead of a block or an entity.

Parameters:

Name Type Description Default
allow_nested_storage_items bool

Determines whether another Storage Item is allowed inside of this item. Default is True.

True
max_slots int

The maximum allowed weight of the sum of all contained items. Maximum is 64. Default is 64.

64
max_weight_limit float

The maximum weight limit of the items in the storage item. Default is 64.0.

required

__iter__()

Iterates over the component's fields.

allowed_items(*items)

List of items that are exclusively allowed in this Storage Item. If empty all items are allowed.

banned_items(*items)

List of items that are not allowed in this Storage Item.

ItemStorageWeightLimit

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(max_weight_limit=64.0)

Specifies the maximum weight limit that a storage item can hold.

Parameters:

Name Type Description Default
max_weight_limit float

The maximum allowed weight of the sum of all contained items. Maximum is 64. Default is 64. Value must be <= 64.

64.0

__iter__()

Iterates over the component's fields.

ItemStorageWeightModifier

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(weight_in_storage_item=4)

Specifies the weight of this item when inside another Storage Item.

Parameters:

Name Type Description Default
weight_in_storage_item int

The weight of this item when inside another Storage Item. Default is 4. 0 means item is not allowed in another Storage Item.

4

__iter__()

Iterates over the component's fields.

ItemThrowable

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(do_swing_animation=False, launch_power_scale=1.0, max_draw_duration=0.0, max_launch_power=1.0, min_draw_duration=0.0, scale_power_by_draw_duration=False)

Sets the throwable item component.

Parameters:

Name Type Description Default
do_swing_animation bool

Whether the item should use the swing animation when thrown. Defaults to False.

False
launch_power_scale float

The scale at which the power of the throw increases. Defaults to 1.0.

1.0
max_draw_duration float

The maximum duration to draw a throwable item. Defaults to 0.0.

0.0
max_launch_power float

The maximum power to launch the throwable item. Defaults to 1.0.

1.0
min_draw_duration float

The minimum duration to draw a throwable item. Defaults to 0.0.

0.0
scale_power_by_draw_duration bool

Whether or not the power of the throw increases with duration charged. When true, The longer you hold, the more power it will have when released. Defaults to False.

False

__iter__()

Iterates over the component's fields.

ItemUseAnimation

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(value)

Determines which animation plays when using an item.

Parameters:

Name Type Description Default
value str

Which animation to play when using an item.

required

__iter__()

Iterates over the component's fields.

ItemUseModifiers

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(use_duration, movement_modifier=1.0)

Determines how long an item takes to use in combination with components such as Shooter, Throwable, or Food.

Parameters:

Name Type Description Default
use_duration float

How long the item takes to use in seconds.

required
movement_modifier float

Modifier value to scale the players movement speed when item is in use. Defaults to 1.0.

1.0

__iter__()

Iterates over the component's fields.

ItemWearable

Bases: _BaseComponent

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

__init__(slot, protection=0)

Sets the wearable item component.

Parameters:

Name Type Description Default
slot Slots

Determines where the item can be worn. If any non-hand slot is chosen, the max stack size is set to 1.

required
protection int

How much protection the wearable has. Defaults to 0.

0
dispensable bool

Whether or not the item can be dispensed from a dispenser. Defaults to True.

required

__iter__()

Iterates over the component's fields.