Skip to main content

InventoryType

Enum InventoryType 

Source
pub enum InventoryType {
Show 25 variants Generic9x1, Generic9x2, Generic9x3, Generic9x4, Generic9x5, Generic9x6, Generic3x3, Crafter3x3, Anvil, Beacon, BlastFurnace, BrewingStand, Crafting, Enchantment, Furnace, Grindstone, Hopper, Lectern, Loom, Merchant, ShulkerBox, Smithing, Smoker, Cartography, Stonecutter,
}
Expand description

Type of inventory window in Minecraft 1.21.4.

Each variant maps to a specific Minecraft protocol ID and has a known slot count. Used when opening custom containers for players.

Variants§

§

Generic9x1

9x1 chest-like inventory (9 slots).

§

Generic9x2

9x2 chest-like inventory (18 slots).

§

Generic9x3

9x3 chest-like inventory (27 slots) – single chest.

§

Generic9x4

9x4 chest-like inventory (36 slots).

§

Generic9x5

9x5 chest-like inventory (45 slots).

§

Generic9x6

9x6 chest-like inventory (54 slots) – double chest.

§

Generic3x3

3x3 dispenser/dropper (9 slots).

§

Crafter3x3

3x3 crafter (9 slots).

§

Anvil

Anvil (3 slots).

§

Beacon

Beacon (1 slot).

§

BlastFurnace

Blast furnace (3 slots).

§

BrewingStand

Brewing stand (5 slots).

§

Crafting

Crafting table (10 slots: 1 output + 3x3 grid).

§

Enchantment

Enchantment table (2 slots).

§

Furnace

Furnace (3 slots).

§

Grindstone

Grindstone (3 slots).

§

Hopper

Hopper (5 slots).

§

Lectern

Lectern (1 slot).

§

Loom

Loom (4 slots).

§

Merchant

Merchant/villager trade (3 slots).

§

ShulkerBox

Shulker box (27 slots).

§

Smithing

Smithing table (4 slots).

§

Smoker

Smoker (3 slots).

§

Cartography

Cartography table (3 slots).

§

Stonecutter

Stonecutter (2 slots).

Implementations§

Source§

impl InventoryType

Source

pub fn protocol_id(&self) -> i32

Returns the Minecraft protocol VarInt ID for this inventory type.

Used when encoding the OpenWindow packet. IDs correspond to the 1.21.4 protocol (0 = generic_9x1 through 24 = stonecutter).

Source

pub fn slot_count(&self) -> usize

Returns the number of container slots this type has.

Does not include the player inventory slots that are appended when the window is opened.

Source

pub fn is_chest_like(&self) -> bool

Returns true if this is a generic chest-like inventory (9xN) or a shulker box.

Chest-like inventories have simple slot layouts where every slot behaves the same (no special output slot, no fuel/product slots).

Source

pub fn has_craft_output(&self) -> bool

Returns true if this inventory has a special crafting output slot at index 0.

Currently only Crafting returns true. The output slot is server-computed from the crafting grid contents.

Trait Implementations§

Source§

impl Clone for InventoryType

Source§

fn clone(&self) -> InventoryType

Returns a duplicate 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 InventoryType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for InventoryType

Source§

fn eq(&self, other: &InventoryType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for InventoryType

Source§

impl Eq for InventoryType

Source§

impl StructuralPartialEq for InventoryType

Auto Trait Implementations§

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
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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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.