Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts
    Item components

    ItemDurabilityComponent

    Class in @minecraft/server

    Extends ItemComponent

    How worn an item with durability is.

    import { ItemDurabilityComponent } from '@minecraft/server';
    import { ItemStack, type ItemDurabilityComponent } from '@minecraft/server';
    const item = new ItemStack('minecraft:diamond_sword');
    const component: ItemDurabilityComponent | undefined = item.getComponent('minecraft:durability');
    if (component) {
    console.log(item.typeId, component.damage);
    }
    import { ItemStack } from '@minecraft/server';
    const item = new ItemStack('minecraft:diamond_sword');
    const component = item.getComponent('minecraft:durability');
    if (component) {
    console.log(item.typeId, component.damage);
    }

    static read-only

    static readonly componentId = "minecraft:durability";
    damage: number;

    How much it’s worn, from 0 to maxDurability. Setting it changes the stack.

    Throws
    • Error outside that range.

    read-only

    readonly maxDurability: number;
    getDamageChance(unbreakingEnchantmentLevel?: number): number;

    The chance in a hundred that a use wears the item, at a level of unbreaking.

    Parameters
    unbreakingEnchantmentLeveloptional
    number
    Returns
    number
    getDamageChanceRange(): { min: number; max: number };
    Returns
    { min: number; max: number }

    ItemComponentTypeMap.durability, ItemComponentTypeMap.minecraft:durability

    From ItemComponent: typeId, isValid