Skip to content

@minecraft/server


@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

typescript
// 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 ​

readonly entity: 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.

InvalidEntityError

Inherited from ​

EntityComponent.entity


isValid ​

readonly isValid: 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 ​

EntityComponent.isValid


totalArmor ​

readonly totalArmor: 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.

InvalidEntityError


totalToughness ​

readonly totalToughness: 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.

InvalidEntityError


typeId ​

readonly typeId: string

Defined in: @minecraft/server/index.d.ts:6240

Remarks ​

Identifier of the component.

Inherited from ​

EntityComponent.typeId


componentId ​

readonly static componentId: "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 ​

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 ​

EquipmentSlot

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

Returns ​

ContainerSlot

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 ​

EquipmentSlot

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

itemStack? ​

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.