Class: EntityEquippableComponent
entity componentBeta
提供对生物装备槽位的访问。此组件存在于玩家实体上。
Provides access to a mob's equipment slots. This component exists on player entities.
Example
givePlayerElytra.ts
Extends
Properties
entity
readonlyentity:Entity
Beta
Remarks
拥有此组件的实体。如果实体已被移除,则实体将为 undefined。
The entity that owns this component. The entity will be undefined if it has been removed.
Throws
This property can throw when used.
Inherited from
isValid
readonlyisValid:boolean
Beta
Remarks
返回该组件是否有效。如果组件的拥有者有效,并且满足组件所需的任何额外验证,则该组件被视为有效。
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.
Inherited from
totalArmor
readonlytotalArmor:number
Beta
Remarks
返回拥有者的总护甲等级。
Returns the total Armor level of the owner.
Throws
This property can throw when used.
totalToughness
readonlytotalToughness:number
Beta
Remarks
返回拥有者的总韧性等级。
Returns the total Toughness level of the owner.
Throws
This property can throw when used.
typeId
readonlytypeId:string
Beta
Remarks
组件的标识符。
Identifier of the component.
Inherited from
componentId
readonlystaticcomponentId:"minecraft:equippable"='minecraft:equippable'
Beta
Methods
getEquipment()
getEquipment(
equipmentSlot):ItemStack|undefined
Beta
Parameters
equipmentSlot
装备槽位,例如 "head"、"chest"、"offhand"。
The equipment slot. e.g. "head", "chest", "offhand"
Returns
ItemStack | undefined
返回装备到给定 EquipmentSlot 的物品。如果为空,则返回 undefined。
Returns the item equipped to the given EquipmentSlot. If empty, returns undefined.
Remarks
获取给定 EquipmentSlot 的已装备物品。
Gets the equipped item for the given EquipmentSlot.
Throws
This function can throw errors.
getEquipmentSlot()
getEquipmentSlot(
equipmentSlot):ContainerSlot
Beta
Parameters
equipmentSlot
装备槽位,例如 "head"、"chest"、"offhand"。
The equipment slot. e.g. "head", "chest", "offhand".
Returns
返回对应于给定 EquipmentSlot 的 ContainerSlot。
Returns the ContainerSlot corresponding to the given EquipmentSlot.
Remarks
获取对应于给定 EquipmentSlot 的 ContainerSlot。
Gets the ContainerSlot corresponding to the given EquipmentSlot.
Throws
This function can throw errors.
setEquipment()
setEquipment(
equipmentSlot,itemStack?):boolean
World Mutation Beta
Parameters
equipmentSlot
装备槽位,例如 "head"、"chest"、"offhand"。
The equipment slot. e.g. "head", "chest", "offhand".
itemStack?
要装备的物品。如果为 undefined,则清空该槽位。
The item to equip. If undefined, clears the slot.
Returns
boolean
Remarks
替换给定 EquipmentSlot 中的物品。
Replaces the item in the given EquipmentSlot.
Throws
This function can throw errors.
