Docs » API reference » Equipment

Equipment

What a player wears and holds ready: the ten slots of the page inside their backpack's door.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from player.equipment().

Methods

MethodDescription
fn defense(&self) -> Result<i64>long defense()Defense from everything worn.
fn attack(&self) -> Result<i64>long attack()Attack of the main-hand weapon.
fn block(&self) -> Result<i64>long block()Block of the off-hand shield.
fn get(&self, slot: GearSlot) -> Result<Option<ItemStack>>Optional<ItemStack> get(GearSlot slot)What a slot holds.
fn set(&self, slot: GearSlot, stack: Option<ItemStack>) -> Result<()>void set(GearSlot slot, ItemStack stack) player_dataPuts a piece on (it must suit the slot), or takes it off to nowhere.
fn swap_hands(&self) -> Result<()>void swapHands() player_dataSwaps the main-hand and off-hand pieces, as SWAP does.

GearSlot

A slot of the equipment page.

One of a fixed set of values.

ValueMeaning
GearSlot::HelmetGearSlot.HELMETHead.
GearSlot::NecklaceGearSlot.NECKLACENeck.
GearSlot::ChestGearSlot.CHESTChest.
GearSlot::LegsGearSlot.LEGSLegs.
GearSlot::BootsGearSlot.BOOTSFeet.
GearSlot::GlovesGearSlot.GLOVESHands.
GearSlot::Ring1GearSlot.RING_1First ring.
GearSlot::Ring2GearSlot.RING_2Second ring.
GearSlot::MainHandGearSlot.MAIN_HANDThe weapon holstered for the main hand.
GearSlot::OffHandGearSlot.OFF_HANDThe shield or weapon holstered for the other hand.