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
Generic9x2
Generic9x3
Generic9x4
Generic9x5
Generic9x6
Generic3x3
Crafter3x3
Anvil
Beacon
BlastFurnace
BrewingStand
Crafting
Enchantment
Furnace
Grindstone
Hopper
Lectern
Loom
Merchant
ShulkerBox
Smithing
Fields
Smoker
CartographyTable
Stonecutter
Implementations§
Source§impl Menu
impl Menu
Sourcepub fn quick_move_stack(&mut self, slot_index: usize) -> ItemSlot
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
.
Sourcepub fn may_place(&self, _target_slot_index: usize, _item: &ItemSlotData) -> bool
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
Sourcepub fn may_pickup(&self, _source_slot_index: usize) -> bool
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
Sourcepub fn max_stack_size(&self, _target_slot_index: usize) -> u32
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
impl Menu
pub const GENERIC9X1_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X1_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X2_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X2_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X3_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X3_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X4_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X4_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X5_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X5_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X6_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC9X6_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GENERIC3X3_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const GENERIC3X3_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const CRAFTER3X3_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const CRAFTER3X3_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const ANVIL_FIRST_SLOT: usize = 0usize
pub const ANVIL_SECOND_SLOT: usize = 1usize
pub const ANVIL_RESULT_SLOT: usize = 2usize
pub const ANVIL_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const BEACON_PAYMENT_SLOT: usize = 0usize
pub const BEACON_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const BLAST_FURNACE_INGREDIENT_SLOT: usize = 0usize
pub const BLAST_FURNACE_FUEL_SLOT: usize = 1usize
pub const BLAST_FURNACE_RESULT_SLOT: usize = 2usize
pub const BLAST_FURNACE_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const BREWING_STAND_BOTTLES_SLOTS: RangeInclusive<usize> = _
pub const BREWING_STAND_INGREDIENT_SLOT: usize = 3usize
pub const BREWING_STAND_FUEL_SLOT: usize = 4usize
pub const BREWING_STAND_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const CRAFTING_RESULT_SLOT: usize = 0usize
pub const CRAFTING_GRID_SLOTS: RangeInclusive<usize> = _
pub const CRAFTING_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const ENCHANTMENT_ITEM_SLOT: usize = 0usize
pub const ENCHANTMENT_LAPIS_SLOT: usize = 1usize
pub const ENCHANTMENT_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const FURNACE_INGREDIENT_SLOT: usize = 0usize
pub const FURNACE_FUEL_SLOT: usize = 1usize
pub const FURNACE_RESULT_SLOT: usize = 2usize
pub const FURNACE_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const GRINDSTONE_INPUT_SLOT: usize = 0usize
pub const GRINDSTONE_ADDITIONAL_SLOT: usize = 1usize
pub const GRINDSTONE_RESULT_SLOT: usize = 2usize
pub const GRINDSTONE_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const HOPPER_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const HOPPER_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const LECTERN_BOOK_SLOT: usize = 0usize
pub const LECTERN_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const LOOM_BANNER_SLOT: usize = 0usize
pub const LOOM_DYE_SLOT: usize = 1usize
pub const LOOM_PATTERN_SLOT: usize = 2usize
pub const LOOM_RESULT_SLOT: usize = 3usize
pub const LOOM_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const MERCHANT_PAYMENTS_SLOTS: RangeInclusive<usize> = _
pub const MERCHANT_RESULT_SLOT: usize = 2usize
pub const MERCHANT_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const SHULKER_BOX_CONTENTS_SLOTS: RangeInclusive<usize> = _
pub const SHULKER_BOX_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const SMITHING_TEMPLATE_SLOT: usize = 0usize
pub const SMITHING_BASE_SLOT: usize = 1usize
pub const SMITHING_ADDITIONAL_SLOT: usize = 2usize
pub const SMITHING_RESULT_SLOT: usize = 3usize
pub const SMITHING_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const SMOKER_INGREDIENT_SLOT: usize = 0usize
pub const SMOKER_FUEL_SLOT: usize = 1usize
pub const SMOKER_RESULT_SLOT: usize = 2usize
pub const SMOKER_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const CARTOGRAPHY_TABLE_MAP_SLOT: usize = 0usize
pub const CARTOGRAPHY_TABLE_ADDITIONAL_SLOT: usize = 1usize
pub const CARTOGRAPHY_TABLE_RESULT_SLOT: usize = 2usize
pub const CARTOGRAPHY_TABLE_PLAYER_SLOTS: RangeInclusive<usize> = _
pub const STONECUTTER_INPUT_SLOT: usize = 0usize
pub const STONECUTTER_RESULT_SLOT: usize = 1usize
pub const STONECUTTER_PLAYER_SLOTS: RangeInclusive<usize> = _
Sourcepub fn slot_mut(&mut self, i: usize) -> Option<&mut ItemSlot>
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.
Sourcepub fn slot(&self, i: usize) -> Option<&ItemSlot>
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.
pub fn from_kind(kind: MenuKind) -> Self
Sourcepub fn slots(&self) -> Vec<ItemSlot>
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
.
Sourcepub fn contents(&self) -> Vec<ItemSlot>
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.
pub fn location_for_slot(&self, i: usize) -> Option<MenuLocation>
Sourcepub fn player_slots_range(&self) -> RangeInclusive<usize>
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.
Sourcepub fn hotbar_slots_range(&self) -> RangeInclusive<usize>
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()];
Sourcepub fn player_slots_without_hotbar_range(&self) -> RangeInclusive<usize>
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.
Sourcepub fn is_hotbar_slot(&self, i: usize) -> bool
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.