pub struct Stack {
pub id: i32,
pub count: i32,
pub damage: i16,
pub nbt: Option<RawNbt>,
}Expand description
A non-empty item stack as the client holds it.
count is a Java int in vanilla (sent as a byte). 1.8 keeps stacks with a count of zero
or less as real stacks (they render as a red “0”); 1.16.5 treats them as empty, so a 1.16.5
Inventory never stores one.
Fields§
§id: i32Numeric item id (1.8: legacy id; 1.16.5: item registry id).
count: i32Stack size.
damage: i161.8 damage / metadata. Always 0 on 1.16.5 (damage lives in the Damage NBT tag).
nbt: Option<RawNbt>Item NBT exactly as received, if any.
Implementations§
Source§impl Stack
impl Stack
Sourcepub fn with_count(&self, count: i32) -> Stack
pub fn with_count(&self, count: i32) -> Stack
The same item (id, damage, NBT) with another count.
Sourcepub fn from_legacy(s: ItemStack) -> Stack
pub fn from_legacy(s: ItemStack) -> Stack
Converts a 1.8 wire stack.
Sourcepub fn from_modern(s: ItemStack) -> Stack
pub fn from_modern(s: ItemStack) -> Stack
Converts a 1.16.5 wire stack.
Sourcepub fn to_legacy(&self) -> ItemStack
pub fn to_legacy(&self) -> ItemStack
The 1.8 wire form (count truncated to a byte like Java’s writeByte).
Sourcepub fn same_item(&self, other: &Stack) -> bool
pub fn same_item(&self, other: &Stack) -> bool
Same item, damage and NBT (vanilla’s item + damage check and its NBT check); counts are not compared.
Sourcepub fn nbt_eq(&self, other: &Stack) -> bool
pub fn nbt_eq(&self, other: &Stack) -> bool
Vanilla’s tag comparison: both absent, or both present and equal as trees.
Sourcepub fn equals_exact(&self, other: &Stack) -> bool
pub fn equals_exact(&self, other: &Stack) -> bool
Exact equality as the server checks the clicked item (count, id, damage, NBT).