Items
src.anvil.api.items
ItemAllowOffHand
Bases: _component
__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 |
ItemBlockPlacer
Bases: _component
__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 |
use_on(*blocks)
List of block descriptors that contain blocks that this item can be used on.
ItemCanDestroyInCreative
Bases: _component
__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 |
ItemCooldown
Bases: _component
__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 |
ItemCustomComponents
Bases: _component
__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. |
()
|
ItemDamage
Bases: _component
__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 |
ItemDigger
Bases: _component
__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. |
()
|
use_efficiency(use_efficiency=False)
Toggles if the item will be used efficiently.
ItemDisplayName
Bases: _component
__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
|
ItemDurability
Bases: _component
__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
|
ItemEnchantable
Bases: _component
__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 |
ItemEntityPlacer
Bases: _component
__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 |
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.
ItemFood
Bases: _component
__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
|
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: _component
__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 |
ItemGlint
Bases: _component
__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 |
ItemHandEquipped
Bases: _component
__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 |
ItemHoverTextColor
Bases: _component
__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 |
ItemIcon
Bases: _component
__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 |
ItemInteractButton
Bases: _component
__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
|
ItemLiquidClipped
Bases: _component
__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 |
ItemMaxStackSize
Bases: _component
__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 |
ItemProjectile
Bases: _component
__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 |
ItemRecord
Bases: _component
__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
|
ItemRepairable
Bases: _component
__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
|
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: _component
__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
|
ItemShouldDespawn
Bases: _component
__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 |
ItemStackedByData
Bases: _component
__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 |
ItemThrowable
Bases: _component
__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
|
ItemUseAnimation
Bases: _component
__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 |
ItemUseModifiers
Bases: _component
__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
|
ItemWearable
Bases: _component
__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 |