Script API - v1.26.10.23
    Preparing search index...

    Class ItemDurabilityComponent

    import { world } from "@minecraft/server";

    const player = world.getPlayers()[0];
    const inventory = player.getComponent("inventory");
    const slot = inventory.container.getSlot(player.selectedSlotIndex);
    let durabilityComp = slot.getItem().getComponent("durability");
    player.sendMessage(
    "Item Durability: " + (durabilityComp.maxDurability - durabilityComp.damage) + "/" + durabilityComp.maxDurability
    );

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    damage: number

    This property can't be edited in read-only mode.

    This property can't be read in early-execution mode.

    isValid: boolean
    maxDurability: number

    This property can throw errors.

    This property can't be read in early-execution mode.

    typeId: string
    unbreakable: boolean

    This property can't be edited in read-only mode.

    This property can't be read in early-execution mode.

    Methods

    • Parameters

      • OptionalunbreakingEnchantmentLevel: number

      Returns number

      This function can't be called in read-only mode.

      This function can throw errors.

      This function can't be called in early-execution mode.