pub struct Slot {
pub item_count: i32,
pub item_id: Option<i32>,
pub component_data: Vec<u8>,
}Expand description
A Minecraft item stack, used in inventories, entity equipment, and trade offers.
The Slot type represents an item stack in the Minecraft protocol. It encodes
the item count, item ID, and optional component data. An empty slot has
item_count = 0 and no other data. A non-empty slot includes the item ID
and an optional list of item components (like damage, enchantments, custom name).
Wire format:
- VarInt
item_count(0 = empty slot, > 0 = slot with item) - If
item_count > 0:- VarInt
item_id - VarInt
num_components_to_add - VarInt
num_components_to_remove - Component data (opaque bytes for now)
- VarInt
Fields§
§item_count: i32The number of items in this stack. 0 means the slot is empty.
item_id: Option<i32>The registry ID of the item, if the slot is not empty.
component_data: Vec<u8>Raw component data bytes. Full component parsing is deferred to a future implementation — for now, the components are stored as opaque bytes to allow roundtrip encoding.
Implementations§
Trait Implementations§
Source§impl Decode for Slot
Decodes a Slot from the Minecraft protocol format.
impl Decode for Slot
Decodes a Slot from the Minecraft protocol format.
Reads the item count. If zero, returns an empty slot. Otherwise reads
the item ID and component counts. Items with zero components decode
cleanly, allowing correct Vec<Slot> support. Items with components
store the raw component data as opaque bytes until a full component
parser is implemented.
Source§impl Encode for Slot
Encodes a Slot in the Minecraft protocol format.
impl Encode for Slot
Encodes a Slot in the Minecraft protocol format.
Empty slots encode as a single VarInt(0). Non-empty slots encode the item count, item ID, then component data. If no components are present, explicit zero counts are written (VarInt(0) + VarInt(0)).
Source§impl EncodedSize for Slot
Computes the wire size of a Slot.
impl EncodedSize for Slot
Computes the wire size of a Slot.