class Rosegold::PlayerInventory

Overview

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

Defined in:

rosegold/inventory/player_inventory.cr

Constant Summary

HOTBAR_SIZE = 9
INVENTORY_SIZE = ItemConstants::InventorySize::PLAYER_INVENTORY
MAIN_INVENTORY_SIZE = 27

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

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

Get slot by index (0-35)


[View source]
def []=(index : Int32, slot : Rosegold::Slot) #

Set slot by index (0-35)


[View source]
def count(&block : Rosegold::Slot -> Bool) : Int32 #

Count items matching predicate


[View source]
def find(&block : Rosegold::Slot -> Bool) : Rosegold::Slot | Nil #

Find first slot matching predicate


[View source]
def first_empty_slot : Int32 | Nil #

Find first empty slot index, returns nil if full


[View source]
def hotbar : Array(Rosegold::Slot) #

Hotbar slots (indices 0-8)


[View source]
def items : Array(Rosegold::Slot) #

Direct access to inventory items (like vanilla)


[View source]
def main_inventory : Array(Rosegold::Slot) #

Main inventory slots (indices 9-35)


[View source]
def selected_slot(selection : UInt8) : Rosegold::Slot #

Get selected hotbar slot (based on client selection)


[View source]
def to_s(io) #

[View source]
def update_slot(index : Int32, slot : Rosegold::Slot) #

Update a specific slot (used by packet handlers)


[View source]
def update_slots(slots : Array(Rosegold::Slot), start_index : Int32 = 0) #

Update multiple slots (used by SetContainerContent)


[View source]