class

Rosegold::PlayerInventory

Inherits Reference / Object

Persistent player inventory that matches vanilla Minecraft's model. This inventory never changes structure (always 36 slots) and persists across container operations.

Constants

HOTBAR_SIZE = SlotOffsets::HOTBAR_SIZE
INVENTORY_SIZE = SlotOffsets::PLAYER_INVENTORY_SIZE
MAIN_INVENTORY_SIZE = SlotOffsets::MAIN_INVENTORY_SIZE

Constructors

Instance methods

[](index : Int32) : Rosegold::Slot

Get slot by index (0-35)

Source
[]=(index : Int32, slot : Rosegold::Slot)

Set slot by index (0-35)

Source
count

Count items matching predicate

Source
find

Find first slot matching predicate

Source
first_empty_slot

Find first empty slot index, returns nil if full

Source
hotbar

Hotbar slots (indices 0-8) - matches vanilla Player.inventory.items

Source
items

Direct access to inventory items (like vanilla)

Source
main_inventory

Main inventory slots (indices 9-35) - matches vanilla Player.inventory.items

Source
selected_slot(selection : UInt8) : Rosegold::Slot

Get selected hotbar slot (based on client selection)

Source
to_s(io)
Source
update_slot(index : Int32, slot : Rosegold::Slot)

Update a specific slot (used by packet handlers)

Source
update_slots(slots : Array(Rosegold::Slot), start_index : Int32 = 0)

Update multiple slots (used by SetContainerContent)

Source