pub struct ContainerHandle(/* private fields */);
Expand description
A handle to the open container. The container will be closed once this is dropped.
Implementations§
Methods from Deref<Target = ContainerHandleRef>§
pub fn close(&self)
Sourcepub fn id(&self) -> i32
pub fn id(&self) -> i32
Get the id of the container. If this is 0, that means it’s the player’s inventory. Otherwise, the number isn’t really meaningful since only one container can be open at a time.
Returns the menu of the container. If the container is closed, this
will return None
.
Note that any modifications you make to the Menu
you’re given will not
actually cause any packets to be sent. If you’re trying to modify your
inventory, use [ContainerHandle::click
] instead
Sourcepub fn contents(&self) -> Option<Vec<ItemStack>>
pub fn contents(&self) -> Option<Vec<ItemStack>>
Returns the item slots in the container, not including the player’s
inventory. If the container is closed, this will return None
.
Sourcepub fn slots(&self) -> Option<Vec<ItemStack>>
pub fn slots(&self) -> Option<Vec<ItemStack>>
Return the contents of the menu, including the player’s inventory. If
the container is closed, this will return None
.
Sourcepub fn left_click(&self, slot: impl Into<usize>)
pub fn left_click(&self, slot: impl Into<usize>)
A shortcut for Self::click
with PickupClick::Left
.
Sourcepub fn shift_click(&self, slot: impl Into<usize>)
pub fn shift_click(&self, slot: impl Into<usize>)
A shortcut for Self::click
with QuickMoveClick::Left
.
Sourcepub fn right_click(&self, slot: impl Into<usize>)
pub fn right_click(&self, slot: impl Into<usize>)
A shortcut for Self::click
with PickupClick::Right
.
pub fn click(&self, operation: impl Into<ClickOperation>)
Trait Implementations§
Source§impl Debug for ContainerHandle
impl Debug for ContainerHandle
Source§impl Deref for ContainerHandle
impl Deref for ContainerHandle
Auto Trait Implementations§
impl Freeze for ContainerHandle
impl !RefUnwindSafe for ContainerHandle
impl Send for ContainerHandle
impl Sync for ContainerHandle
impl Unpin for ContainerHandle
impl !UnwindSafe for ContainerHandle
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§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>
, which can then be
downcast
into Box<dyn 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>
, which 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.