pub struct InventoryKind {
result_container: Shared<ResultContainer>,
handler: CraftingHandler,
result: Section,
grid: Section,
armor: Section,
inv: Section,
main: Section,
hotbar: Section,
offhand: Section,
}Expand description
Per-menu player-inventory state: recipe handler, result container, and the section handles for its custom shift-click.
Fields§
§result_container: Shared<ResultContainer>The result container.
handler: CraftingHandler§result: SectionThe result (slot 0).
grid: SectionThe 2x2 grid (slots 1-4).
armor: SectionArmor slots (slots 5-8).
inv: SectionMain inventory + hotbar (slots 9-44).
main: SectionMain inventory (slots 9-35).
hotbar: SectionHotbar (slots 36-44).
offhand: SectionOffhand (slot 45).
Implementations§
Source§impl InventoryKind
impl InventoryKind
Sourcepub(crate) fn crafting_id(&self) -> ContainerId
pub(crate) fn crafting_id(&self) -> ContainerId
ContainerId of the 2x2 grid.
Sourcepub(crate) fn crafting_container(&self) -> Shared<CraftingContainer>
pub(crate) fn crafting_container(&self) -> Shared<CraftingContainer>
Shared handle to the 2x2 grid container.
Sourcepub(crate) fn crafting_handler(&self) -> CraftingHandler
pub(crate) fn crafting_handler(&self) -> CraftingHandler
Shared recipe handler for the 2x2 crafting grid and its result.
Sourcepub(crate) fn update_result(&self, guard: &mut ContainerLockGuard)
pub(crate) fn update_result(&self, guard: &mut ContainerLockGuard)
Recomputes the result from the current grid contents.
Sourcefn move_between_inventory_and_hotbar(
&self,
behavior: &MenuBehavior,
guard: &mut ContainerLockGuard,
slot_index: usize,
stack: &mut ItemStack,
) -> bool
fn move_between_inventory_and_hotbar( &self, behavior: &MenuBehavior, guard: &mut ContainerLockGuard, slot_index: usize, stack: &mut ItemStack, ) -> bool
Moves items between the main inventory and hotbar.
Trait Implementations§
Source§impl DowncastType for InventoryKind
impl DowncastType for InventoryKind
Source§const TYPE_KEY: DowncastTypeKey
const TYPE_KEY: DowncastTypeKey
Source§impl MenuKind for InventoryKind
impl MenuKind for InventoryKind
Source§fn quick_move(
&mut self,
behavior: &mut MenuBehavior,
guard: &mut ContainerLockGuard,
slot_index: usize,
player: &Player,
) -> Option<ItemStack>
fn quick_move( &mut self, behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, slot_index: usize, player: &Player, ) -> Option<ItemStack>
Handles shift-click for a slot, including armor/offhand auto-equip.
Always returns Some: the item originally in the slot, or empty if
nothing moved.
Source§fn can_take_item_for_pick_all(
&self,
_carried: &ItemStack,
slot_index: usize,
) -> bool
fn can_take_item_for_pick_all( &self, _carried: &ItemStack, slot_index: usize, ) -> bool
Prevents taking from the result slot during pickup-all.
Source§fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
Clears the virtual result on close. The grid is drained by Menu::removed.
Source§fn slots_changed(
&mut self,
_behavior: &mut MenuBehavior,
guard: &mut ContainerLockGuard,
_player: &Player,
)
fn slots_changed( &mut self, _behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, _player: &Player, )
Source§fn on_rename(
&mut self,
_behavior: &mut MenuBehavior,
_name: String,
_player: &Player,
)
fn on_rename( &mut self, _behavior: &mut MenuBehavior, _name: String, _player: &Player, )
Source§fn on_open(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_player: &Player,
)
fn on_open( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )
Source§fn on_tick(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_player: &Player,
)
fn on_tick( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )
Source§fn on_slot_clicked(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_click: Click,
_player: &Player,
) -> ClickOutcome
fn on_slot_clicked( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _click: Click, _player: &Player, ) -> ClickOutcome
ClickOutcome::Consume to treat the slot as a button, or
ClickOutcome::Fallthrough for default handling.Source§fn on_drag(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_action: QuickCraft,
_player: &Player,
) -> ClickOutcome
fn on_drag( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _action: QuickCraft, _player: &Player, ) -> ClickOutcome
ClickOutcome::Consume to cancel the drag.Source§fn can_drag_to(&self, _slot_index: usize) -> bool
fn can_drag_to(&self, _slot_index: usize) -> bool
slot_index.Source§fn still_valid(&self, _behavior: &MenuBehavior, _player: &Player) -> bool
fn still_valid(&self, _behavior: &MenuBehavior, _player: &Player) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for InventoryKind
impl !UnwindSafe for InventoryKind
impl Freeze for InventoryKind
impl Send for InventoryKind
impl Sync for InventoryKind
impl Unpin for InventoryKind
impl UnsafeUnpin for InventoryKind
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> Downcast for Twhere
T: ErasedType + ?Sized,
impl<T> Downcast for Twhere
T: ErasedType + ?Sized,
Source§fn is<T>(&self) -> boolwhere
T: DowncastType,
fn is<T>(&self) -> boolwhere
T: DowncastType,
T.Source§fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
T when its key matches.Source§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
T when its key matches.Source§impl<T> ErasedType for Twhere
T: DowncastType,
impl<T> ErasedType for Twhere
T: DowncastType,
fn downcast_type_key(&self) -> DowncastTypeKey
fn downcast_data(&self) -> *const ()
fn downcast_data_mut(&mut self) -> *mut ()
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>