Enum azalea::inventory::Menu

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

A menu, which is a fixed collection of slots.

Variants§

§

Player(Player)

§

Generic9x1

Fields

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

Generic9x2

Fields

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

Generic9x3

Fields

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

Generic9x4

Fields

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

Generic9x5

Fields

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

Generic9x6

Fields

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

Generic3x3

Fields

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

Crafter3x3

Fields

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

Anvil

Fields

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

Beacon

Fields

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

BlastFurnace

Fields

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

BrewingStand

Fields

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

Crafting

Fields

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

Enchantment

Fields

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

Furnace

Fields

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

Grindstone

Fields

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

Hopper

Fields

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

Lectern

Fields

§player: SlotList<36>
§

Loom

Fields

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

Merchant

Fields

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

ShulkerBox

Fields

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

Smithing

Fields

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

Smoker

Fields

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

CartographyTable

Fields

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

Stonecutter

Fields

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

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) -> Menu

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<(), Error>

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
§

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

§

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

§

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

§

fn type_name(&self) -> &'static str

Gets the type name of self
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
§

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> Downcast for T
where T: AsAny + ?Sized,

§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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