pub struct Inventory {
pub inventory_menu: Menu,
pub id: u8,
pub container_menu: Option<Menu>,
pub container_menu_title: Option<FormattedText>,
pub carried: ItemSlot,
pub state_id: u32,
pub quick_craft_status: QuickCraftStatusKind,
pub quick_craft_kind: QuickCraftKind,
pub quick_craft_slots: HashSet<u16>,
pub selected_hotbar_slot: u8,
}
Expand description
A component present on all local players that have an inventory.
Fields§
A component that contains the player’s inventory menu. This is
guaranteed to be a Menu::Player
.
We keep it as a Menu
since Menu
has some useful functions that
bare azalea_inventory::Player
doesn’t have.
id: u8
The ID of the container that’s currently open. Its value is not guaranteed to be anything specific, and may change every time you open a container (unless it’s 0, in which case it means that no container is open).
The current container menu that the player has open. If no container is
open, this will be None
.
The custom name of the menu that’s currently open. This is Some when
container_menu
is Some.
carried: ItemSlot
The item that is currently held by the cursor. Slot::Empty
if nothing
is currently being held.
This is different from Self::selected_hotbar_slot
, which is the
item that’s selected in the hotbar.
state_id: u32
An identifier used by the server to track client inventory desyncs. This is sent on every container click, and it’s only ever updated when the server sends a new container update.
quick_craft_status: QuickCraftStatusKind
§quick_craft_kind: QuickCraftKind
§quick_craft_slots: HashSet<u16>
A set of the indexes of the slots that have been right clicked in this “quick craft”.
selected_hotbar_slot: u8
The index of the item in the hotbar that’s currently being held by the player. This MUST be in the range 0..9 (not including 9).
In a vanilla client this is changed by pressing the number keys or using the scroll wheel.
Implementations§
Source§impl Inventory
impl Inventory
Returns a reference to the currently active menu. If a container is open
it’ll return Self::container_menu
, otherwise
Self::inventory_menu
.
Use Self::menu_mut
if you need a mutable reference.
Returns a mutable reference to the currently active menu. If a container
is open it’ll return Self::container_menu
, otherwise
Self::inventory_menu
.
Use Self::menu
if you don’t need a mutable reference.
Sourcepub fn simulate_click(
&mut self,
operation: &ClickOperation,
player_abilities: &PlayerAbilities,
)
pub fn simulate_click( &mut self, operation: &ClickOperation, player_abilities: &PlayerAbilities, )
Modify the inventory as if the given operation was performed on it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inventory
impl !RefUnwindSafe for Inventory
impl Send for Inventory
impl Sync for Inventory
impl Unpin for Inventory
impl !UnwindSafe for Inventory
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
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.§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World
].