Skip to main content

EntityEquipment

Trait EntityEquipment 

Source
pub trait EntityEquipment: Send {
    // Required methods
    fn get_ref(&self, slot: EquipmentSlot) -> &ItemStack;
    fn get_mut(&mut self, slot: EquipmentSlot) -> &mut ItemStack;
    fn set(&mut self, slot: EquipmentSlot, stack: ItemStack) -> ItemStack;
    fn take(&mut self, slot: EquipmentSlot) -> ItemStack;
    fn clear(&mut self);

    // Provided method
    fn non_empty_items(&self) -> Vec<(EquipmentSlot, ItemStack)> { ... }
}
Expand description

Equipment access shared by player inventories and owned entity storage.

Required Methods§

Source

fn get_ref(&self, slot: EquipmentSlot) -> &ItemStack

Gets a reference to the item in a slot.

Source

fn get_mut(&mut self, slot: EquipmentSlot) -> &mut ItemStack

Gets a mutable reference to the item in a slot.

Source

fn set(&mut self, slot: EquipmentSlot, stack: ItemStack) -> ItemStack

Sets the item in a slot, returning the old item.

Source

fn take(&mut self, slot: EquipmentSlot) -> ItemStack

Takes the item from a slot, leaving an empty stack in its place.

Source

fn clear(&mut self)

Clears all equipment slots.

Provided Methods§

Source

fn non_empty_items(&self) -> Vec<(EquipmentSlot, ItemStack)>

Returns non-empty equipment slots for initial spawn synchronization.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§