azalea_inventory

Enum Menu

Source
pub enum Menu {
Show 26 variants Player(Player), Generic9x1 { contents: SlotList<9usize>, player: SlotList<36usize>, }, Generic9x2 { contents: SlotList<18usize>, player: SlotList<36usize>, }, Generic9x3 { contents: SlotList<27usize>, player: SlotList<36usize>, }, Generic9x4 { contents: SlotList<36usize>, player: SlotList<36usize>, }, Generic9x5 { contents: SlotList<45usize>, player: SlotList<36usize>, }, Generic9x6 { contents: SlotList<54usize>, player: SlotList<36usize>, }, Generic3x3 { contents: SlotList<9usize>, player: SlotList<36usize>, }, Crafter3x3 { contents: SlotList<9usize>, player: SlotList<36usize>, }, Anvil { first: ItemSlot, second: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Beacon { payment: ItemSlot, player: SlotList<36usize>, }, BlastFurnace { ingredient: ItemSlot, fuel: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, BrewingStand { bottles: SlotList<3usize>, ingredient: ItemSlot, fuel: ItemSlot, player: SlotList<36usize>, }, Crafting { result: ItemSlot, grid: SlotList<9usize>, player: SlotList<36usize>, }, Enchantment { item: ItemSlot, lapis: ItemSlot, player: SlotList<36usize>, }, Furnace { ingredient: ItemSlot, fuel: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Grindstone { input: ItemSlot, additional: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Hopper { contents: SlotList<5usize>, player: SlotList<36usize>, }, Lectern { book: ItemSlot, player: SlotList<36usize>, }, Loom { banner: ItemSlot, dye: ItemSlot, pattern: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Merchant { payments: SlotList<2usize>, result: ItemSlot, player: SlotList<36usize>, }, ShulkerBox { contents: SlotList<27usize>, player: SlotList<36usize>, }, Smithing { template: ItemSlot, base: ItemSlot, additional: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Smoker { ingredient: ItemSlot, fuel: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, CartographyTable { map: ItemSlot, additional: ItemSlot, result: ItemSlot, player: SlotList<36usize>, }, Stonecutter { input: ItemSlot, result: ItemSlot, player: SlotList<36usize>, },
}
Expand description

A menu, which is a fixed collection of slots.

Variants§

§

Player(Player)

§

Generic9x1

Fields

§contents: SlotList<9usize>
§player: SlotList<36usize>
§

Generic9x2

Fields

§contents: SlotList<18usize>
§player: SlotList<36usize>
§

Generic9x3

Fields

§contents: SlotList<27usize>
§player: SlotList<36usize>
§

Generic9x4

Fields

§contents: SlotList<36usize>
§player: SlotList<36usize>
§

Generic9x5

Fields

§contents: SlotList<45usize>
§player: SlotList<36usize>
§

Generic9x6

Fields

§contents: SlotList<54usize>
§player: SlotList<36usize>
§

Generic3x3

Fields

§contents: SlotList<9usize>
§player: SlotList<36usize>
§

Crafter3x3

Fields

§contents: SlotList<9usize>
§player: SlotList<36usize>
§

Anvil

Fields

§first: ItemSlot
§second: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Beacon

Fields

§payment: ItemSlot
§player: SlotList<36usize>
§

BlastFurnace

Fields

§ingredient: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

BrewingStand

Fields

§bottles: SlotList<3usize>
§ingredient: ItemSlot
§player: SlotList<36usize>
§

Crafting

Fields

§result: ItemSlot
§grid: SlotList<9usize>
§player: SlotList<36usize>
§

Enchantment

Fields

§lapis: ItemSlot
§player: SlotList<36usize>
§

Furnace

Fields

§ingredient: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Grindstone

Fields

§input: ItemSlot
§additional: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Hopper

Fields

§contents: SlotList<5usize>
§player: SlotList<36usize>
§

Lectern

Fields

§player: SlotList<36usize>
§

Loom

Fields

§banner: ItemSlot
§pattern: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Merchant

Fields

§payments: SlotList<2usize>
§result: ItemSlot
§player: SlotList<36usize>
§

ShulkerBox

Fields

§contents: SlotList<27usize>
§player: SlotList<36usize>
§

Smithing

Fields

§template: ItemSlot
§additional: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Smoker

Fields

§ingredient: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

CartographyTable

Fields

§additional: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>
§

Stonecutter

Fields

§input: ItemSlot
§result: ItemSlot
§player: SlotList<36usize>

Implementations§

Source§

impl Menu

Source

pub fn quick_move_stack(&mut self, slot_index: usize) -> ItemSlot

Shift-click a slot in this menu.

Keep in mind that this doesn’t send any packets to the server, it just mutates this specific Menu.

Source

pub fn may_place(&self, _target_slot_index: usize, _item: &ItemSlotData) -> bool

Whether the given item could be placed in this menu.

TODO: right now this always returns true

Source

pub fn may_pickup(&self, _source_slot_index: usize) -> bool

Whether the item in the given slot could be clicked and picked up. TODO: right now this always returns true

Source

pub fn max_stack_size(&self, _target_slot_index: usize) -> u32

Get the maximum number of items that can be placed in this slot.

Source§

impl Menu

Source

pub fn as_player(&self) -> &Player

Get the Player from this Menu.

§Panics

Will panic if the menu isn’t Menu::Player.

Source§

impl Menu

Source

pub const GENERIC9X1_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X1_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X2_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X2_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X3_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X3_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X4_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X4_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X5_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X5_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X6_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC9X6_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC3X3_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const GENERIC3X3_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const CRAFTER3X3_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const CRAFTER3X3_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const ANVIL_FIRST_SLOT: usize = 0usize

Source

pub const ANVIL_SECOND_SLOT: usize = 1usize

Source

pub const ANVIL_RESULT_SLOT: usize = 2usize

Source

pub const ANVIL_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const BEACON_PAYMENT_SLOT: usize = 0usize

Source

pub const BEACON_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const BLAST_FURNACE_INGREDIENT_SLOT: usize = 0usize

Source

pub const BLAST_FURNACE_FUEL_SLOT: usize = 1usize

Source

pub const BLAST_FURNACE_RESULT_SLOT: usize = 2usize

Source

pub const BLAST_FURNACE_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const BREWING_STAND_BOTTLES_SLOTS: RangeInclusive<usize> = _

Source

pub const BREWING_STAND_INGREDIENT_SLOT: usize = 3usize

Source

pub const BREWING_STAND_FUEL_SLOT: usize = 4usize

Source

pub const BREWING_STAND_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const CRAFTING_RESULT_SLOT: usize = 0usize

Source

pub const CRAFTING_GRID_SLOTS: RangeInclusive<usize> = _

Source

pub const CRAFTING_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const ENCHANTMENT_ITEM_SLOT: usize = 0usize

Source

pub const ENCHANTMENT_LAPIS_SLOT: usize = 1usize

Source

pub const ENCHANTMENT_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const FURNACE_INGREDIENT_SLOT: usize = 0usize

Source

pub const FURNACE_FUEL_SLOT: usize = 1usize

Source

pub const FURNACE_RESULT_SLOT: usize = 2usize

Source

pub const FURNACE_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const GRINDSTONE_INPUT_SLOT: usize = 0usize

Source

pub const GRINDSTONE_ADDITIONAL_SLOT: usize = 1usize

Source

pub const GRINDSTONE_RESULT_SLOT: usize = 2usize

Source

pub const GRINDSTONE_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const HOPPER_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const HOPPER_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const LECTERN_BOOK_SLOT: usize = 0usize

Source

pub const LECTERN_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const LOOM_BANNER_SLOT: usize = 0usize

Source

pub const LOOM_DYE_SLOT: usize = 1usize

Source

pub const LOOM_PATTERN_SLOT: usize = 2usize

Source

pub const LOOM_RESULT_SLOT: usize = 3usize

Source

pub const LOOM_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const MERCHANT_PAYMENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const MERCHANT_RESULT_SLOT: usize = 2usize

Source

pub const MERCHANT_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const SHULKER_BOX_CONTENTS_SLOTS: RangeInclusive<usize> = _

Source

pub const SHULKER_BOX_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const SMITHING_TEMPLATE_SLOT: usize = 0usize

Source

pub const SMITHING_BASE_SLOT: usize = 1usize

Source

pub const SMITHING_ADDITIONAL_SLOT: usize = 2usize

Source

pub const SMITHING_RESULT_SLOT: usize = 3usize

Source

pub const SMITHING_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const SMOKER_INGREDIENT_SLOT: usize = 0usize

Source

pub const SMOKER_FUEL_SLOT: usize = 1usize

Source

pub const SMOKER_RESULT_SLOT: usize = 2usize

Source

pub const SMOKER_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const CARTOGRAPHY_TABLE_MAP_SLOT: usize = 0usize

Source

pub const CARTOGRAPHY_TABLE_ADDITIONAL_SLOT: usize = 1usize

Source

pub const CARTOGRAPHY_TABLE_RESULT_SLOT: usize = 2usize

Source

pub const CARTOGRAPHY_TABLE_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub const STONECUTTER_INPUT_SLOT: usize = 0usize

Source

pub const STONECUTTER_RESULT_SLOT: usize = 1usize

Source

pub const STONECUTTER_PLAYER_SLOTS: RangeInclusive<usize> = _

Source

pub fn slot_mut(&mut self, i: usize) -> Option<&mut ItemSlot>

Get a mutable reference to the ItemSlot at the given protocol index.

If you’re trying to get an item in a menu without caring about protocol indexes, you should just match it and index the ItemSlot you get.

Use Menu::slot if you don’t need a mutable reference to the slot.

§Errors

Returns None if the index is out of bounds.

Source

pub fn slot(&self, i: usize) -> Option<&ItemSlot>

Get a reference to the ItemSlot at the given protocol index.

If you’re trying to get an item in a menu without caring about protocol indexes, you should just match it and index the ItemSlot you get.

Use Menu::slot_mut if you need a mutable reference to the slot.

§Errors

Returns None if the index is out of bounds.

Source

pub const fn len(&self) -> usize

Returns the number of slots in the menu.

Source

pub fn from_kind(kind: MenuKind) -> Self

Source

pub fn slots(&self) -> Vec<ItemSlot>

Return the contents of the menu, including the player’s inventory.

The indexes in this will match up with Menu::slot_mut.

If you don’t want to include the player’s inventory, use Menu::contents instead.

If you only want to include the players inventory, then you can filter by only using the slots in Self::player_slots_range.

Source

pub fn contents(&self) -> Vec<ItemSlot>

Return the contents of the menu, not including the player’s inventory.

If you want to include the player’s inventory, use Menu::slots instead.

Source

pub fn location_for_slot(&self, i: usize) -> Option<MenuLocation>

Source

pub fn player_slots_range(&self) -> RangeInclusive<usize>

Get the range of slot indexes that contain the player’s inventory. This may be different for each menu.

Source

pub fn hotbar_slots_range(&self) -> RangeInclusive<usize>

Get the range of slot indexes that contain the player’s hotbar. This may be different for each menu.

let hotbar_items = &inventory.slots()[inventory.hotbar_slots_range()];
Source

pub fn player_slots_without_hotbar_range(&self) -> RangeInclusive<usize>

Get the range of slot indexes that contain the player’s inventory, not including the hotbar. This may be different for each menu.

Source

pub fn is_hotbar_slot(&self, i: usize) -> bool

Returns whether the given index would be in the player’s hotbar.

Equivalent to self.hotbar_slots_range().contains(&i).

Trait Implementations§

Source§

impl Clone for Menu

Source§

fn clone(&self) -> Menu

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Menu

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Menu

§

impl !RefUnwindSafe for Menu

§

impl Send for Menu

§

impl Sync for Menu

§

impl Unpin for Menu

§

impl !UnwindSafe for Menu

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more