@minecraft/server / EntityEquippableComponent
Class: EntityEquippableComponent ​
Defined in: @minecraft/server/index.d.ts:10213
Provides access to a mob's equipment slots. This component exists on player entities.
Example ​
givePlayerElytra.ts
// 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));
}
}Extends ​
Properties ​
entity ​
readonlyentity:Entity
Defined in: @minecraft/server/index.d.ts:9981
Remarks ​
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
Defined in: @minecraft/server/index.d.ts:6234
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
Defined in: @minecraft/server/index.d.ts:10223
Remarks ​
Returns the total Armor level of the owner.
Throws ​
This property can throw when used.
totalToughness ​
readonlytotalToughness:number
Defined in: @minecraft/server/index.d.ts:10232
Remarks ​
Returns the total Toughness level of the owner.
Throws ​
This property can throw when used.
typeId ​
readonlytypeId:string
Defined in: @minecraft/server/index.d.ts:6240
Remarks ​
Identifier of the component.
Inherited from ​
componentId ​
readonlystaticcomponentId:"minecraft:equippable"='minecraft:equippable'
Defined in: @minecraft/server/index.d.ts:10233
Methods ​
getEquipment() ​
getEquipment(
equipmentSlot):ItemStack|undefined
Defined in: @minecraft/server/index.d.ts:10245
Parameters ​
equipmentSlot ​
The equipment slot. e.g. "head", "chest", "offhand"
Returns ​
ItemStack | undefined
Returns the item equipped to the given EquipmentSlot. If empty, returns undefined.
Remarks ​
Gets the equipped item for the given EquipmentSlot.
Throws ​
This function can throw errors.
getEquipmentSlot() ​
getEquipmentSlot(
equipmentSlot):ContainerSlot
Defined in: @minecraft/server/index.d.ts:10258
Parameters ​
equipmentSlot ​
The equipment slot. e.g. "head", "chest", "offhand".
Returns ​
Returns the ContainerSlot corresponding to the given EquipmentSlot.
Remarks ​
Gets the ContainerSlot corresponding to the given EquipmentSlot.
Throws ​
This function can throw errors.
setEquipment() ​
setEquipment(
equipmentSlot,itemStack?):boolean
Defined in: @minecraft/server/index.d.ts:10271
Parameters ​
equipmentSlot ​
The equipment slot. e.g. "head", "chest", "offhand".
itemStack? ​
The item to equip. If undefined, clears the slot.
Returns ​
boolean
Remarks ​
Replaces the item in the given EquipmentSlot.
This function can't be called in restricted-execution mode.
Throws ​
This function can throw errors.