module
Rosegold::InventoryOperations
Overview
Shared operations for inventory and container menus Extracts common logic from both ContainerMenu and InventoryMenu
Direct including types
Defined in:
rosegold/inventory/inventory_operations.crInstance Method Summary
-
#[](index : Int32) : Rosegold::Slot
Abstract methods that must be implemented by including classes
- #[]=(index : Int32, slot : Rosegold::Slot)
- #allow_modification?(slot_index : Int32) : Bool
-
#can_stack?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool
Check if two slots can be stacked together
-
#check_and_fix_desync
Check for desync and request refresh if needed (vanilla-style recovery)
-
#content : Array(Rosegold::WindowSlot)
Shared compatibility methods
- #content_slots : Array(Rosegold::WindowSlot)
-
#copy_slot(slot : Rosegold::Slot) : Rosegold::Slot
Create a deep copy of a slot
-
#cursor : Rosegold::Slot
Cursor slot management
- #cursor=(cursor : Rosegold::Slot)
-
#get_max_stack_size(item_slot : Rosegold::Slot) : Int32
Get max stack size for an item
- #get_slot_max_stack_size(slot_index : Int32, item_slot : Rosegold::Slot) : Int32
- #hotbar : Array(Rosegold::WindowSlot)
- #hotbar_slot_index(hotbar_nr : Int32) : Int32
-
#hotbar_slots : Array(Rosegold::WindowSlot)
Player inventory delegation methods
-
#increment_state_id : UInt32
Vanilla state ID increment with 15-bit wraparound (matches vanilla's incrementStateId)
- #inventory : Array(Rosegold::WindowSlot)
- #inventory_slots : Array(Rosegold::WindowSlot)
- #main_hand : Rosegold::Slot
- #main_inventory_slots : Array(Rosegold::Slot)
- #may_pickup?(slot_index : Int32) : Bool
- #may_place?(slot_index : Int32, item_slot : Rosegold::Slot) : Bool
- #menu_id : UInt8
-
#move_item_stack_to(source_index : Int32, target_start : Int32, target_end : Int32, reverse : Bool = false) : Bool
Vanilla's moveItemStackTo equivalent - exact implementation from AbstractContainerMenu.java
-
#offhand_slot_index : Int32
Abstract methods for slot index calculations (different per menu type)
-
#perform_cursor_drop_operation(button : Int32)
Shared cursor drop operation (identical in both menus)
-
#perform_drop_operation(slot_index : Int32, button : Int32)
Shared drop operation (identical in both menus)
-
#perform_hotbar_swap(slot_index : Int32, button : Int32)
Shared hotbar swap for click operations (identical validation logic)
-
#perform_offhand_swap_operation(slot_index : Int32)
Shared off-hand swap operation (identical in both menus)
-
#perform_regular_click(slot_index : Int32, button : Int32)
Shared regular click operation (identical vanilla logic in both menus)
-
#perform_shift_click(slot_index : Int32)
Keep existing abstract methods
-
#safe_insert(target_slot_index : Int32, cursor_slot : Rosegold::Slot, amount : Int32)
Vanilla's safeInsert equivalent - safely insert items from cursor to slot
-
#safe_take(source_slot_index : Int32, amount : Int32)
Vanilla's tryRemove/safeTake equivalent - safely take items from slot
-
#same_item_same_components?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool
Check if two slots have the same item and components (for stacking)
-
#send_click(slot_index : Int32, button : Int32, click_type)
Send container click packet with vanilla client-side logic
-
#slots : Array(Rosegold::WindowSlot)
Shared slot conversion to WindowSlots (identical in both menus)
- #slots=(new_slots : Array(Rosegold::WindowSlot))
-
#slots_match?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool
Helper method to compare if two slots are equivalent (vanilla's ItemStack.matches equivalent)
- #swap_hotbar(hotbar_nr, slot : Rosegold::WindowSlot)
-
#swap_hotbar(hotbar_nr, slot_number)
Shared hotbar swap operation with abstracted slot calculations
- #to_s(io)
- #total_slots : Int32
-
#update_all_slots(slots : Array(Rosegold::Slot), cursor : Rosegold::Slot, packet_state_id : UInt32)
Update all slots from SetContainerContent packet (vanilla behavior - no validation)
-
#update_slot(index : Int32, slot : Rosegold::Slot, packet_state_id : UInt32)
Update single slot (vanilla behavior - no validation)
Instance Method Detail
Abstract methods that must be implemented by including classes
Check if two slots can be stacked together
Get max stack size for an item
Vanilla state ID increment with 15-bit wraparound (matches vanilla's incrementStateId)
Vanilla's moveItemStackTo equivalent - exact implementation from AbstractContainerMenu.java
Abstract methods for slot index calculations (different per menu type)
Shared cursor drop operation (identical in both menus)
Shared drop operation (identical in both menus)
Shared hotbar swap for click operations (identical validation logic)
Shared off-hand swap operation (identical in both menus)
Shared regular click operation (identical vanilla logic in both menus)
Vanilla's safeInsert equivalent - safely insert items from cursor to slot
Vanilla's tryRemove/safeTake equivalent - safely take items from slot
Check if two slots have the same item and components (for stacking)
Send container click packet with vanilla client-side logic
Shared slot conversion to WindowSlots (identical in both menus)
Helper method to compare if two slots are equivalent (vanilla's ItemStack.matches equivalent)
Shared hotbar swap operation with abstracted slot calculations
Update all slots from SetContainerContent packet (vanilla behavior - no validation)
Update single slot (vanilla behavior - no validation)