@minecraft
    正在准备搜索索引...

    类 EntityEquippableComponent

    Provides access to a mob's equipment slots. This component exists on player entities.

    // Gives the player Elytra
    import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
    import { MinecraftItemTypes } from '@minecraft/vanilla-data';

    function giveEquipment(player: Player) {
    const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
    if (equipmentCompPlayer) {
    equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra));
    }
    }

    层级 (查看层级一览)

    索引
    entity: Entity

    The entity that owns this component. The entity will be undefined if it has been removed.

    isValid: boolean

    Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.

    totalArmor: number

    Returns the total Armor level of the owner.

    totalToughness: number

    Returns the total Toughness level of the owner.

    typeId: string

    Identifier of the component.

    componentId: "minecraft:equippable" = 'minecraft:equippable'
    • 世界修改

      参数

      • equipmentSlot: EquipmentSlot

        The equipment slot. e.g. "head", "chest", "offhand".

      • 可选itemStack: ItemStack

        The item to equip. If undefined, clears the slot.

      返回 boolean

      Replaces the item in the given EquipmentSlot.