abstract class Rosegold::Menu

Overview

Abstract base for all menu types (player inventory, chest, furnace, etc.) Replaces the previous InventoryOperations module + InventoryMenu/ContainerMenu split.

Direct Known Subclasses

Defined in:

rosegold/inventory/menu.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Rosegold::Client, player_inventory : Rosegold::PlayerInventory) #

[View source]

Instance Method Detail

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

Slot access


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

[View source]
abstract def allow_modification?(slot_index : Int32) : Bool #

[View source]
def can_stack?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool #

[View source]
def check_and_fix_desync #

[View source]
def close #

[View source]
abstract def container_slots : Array(Rosegold::WindowSlot) #

[View source]
def content : Array(Rosegold::WindowSlot) #

[View source]
def content_loaded? : Bool #

[View source]
def copy_slot(slot : Rosegold::Slot) : Rosegold::Slot #

[View source]
def crafting_grid_range : Range(Int32, Int32) #

Slot indices for the crafting grid (1..9 for crafting table, 1..4 for player inventory).


[View source]
def crafting_result_move_end : Int32 #

Exclusive end index for moving crafting results into player inventory.


[View source]
def cursor : Rosegold::Slot #

[View source]
def cursor=(cursor : Rosegold::Slot) #

[View source]
def get_max_stack_size(item_slot : Rosegold::Slot) : Int32 #

[View source]
abstract def get_slot_max_stack_size(slot_index : Int32, item_slot : Rosegold::Slot) : Int32 #

[View source]
def handle_close #

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

[View source]
abstract def hotbar_slot_index(hotbar_nr : Int32) : Int32 #

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

[View source]
abstract def hotbar_window_slots : Array(Rosegold::WindowSlot) #

[View source]
def id : UInt8 #

[View source]
def invalidate_content : Nil #

[View source]
def inventory : Array(Rosegold::WindowSlot) #

[View source]
abstract def inventory_slots : Array(Rosegold::WindowSlot) #

[View source]
def main_hand : Rosegold::Slot #

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

[View source]
abstract def may_pickup?(slot_index : Int32) : Bool #

[View source]
abstract def may_place?(slot_index : Int32, item_slot : Rosegold::Slot) : Bool #

Slot validation


[View source]
abstract def menu_id : UInt8 #

[View source]
def move_item_stack_to(source_index : Int32, target_start : Int32, target_end : Int32, reverse : Bool = false) : Bool #

[View source]
abstract def offhand_slot_index : Int32 #

Slot group accessors


[View source]
def perform_cursor_drop_operation(button : Int32) #

[View source]
def perform_drop_operation(slot_index : Int32, button : Int32) #

[View source]
def perform_hotbar_swap(slot_index : Int32, button : Int32) #

[View source]
def perform_offhand_swap_operation(slot_index : Int32) #

[View source]
def perform_regular_click(slot_index : Int32, button : Int32) #

[View source]
def perform_shift_click(slot_index : Int32) #

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

[View source]
abstract def player_inventory_start : Int32 #

Player inventory start offset within this menu


[View source]
def player_window_slots : Array(Rosegold::WindowSlot) #

[View source]
def properties : Hash(Int16, Int16) #

[View source]
def properties=(properties : Hash(Int16, Int16)) #

[View source]
abstract def quick_move_stack(slot_index : Int32) : Rosegold::Slot #

Shift-click routing (each menu subclass defines where items move)


[View source]
def receive_content(packet : Clientbound::SetContainerContent) : Nil #

[View source]
def safe_insert(target_slot_index : Int32, cursor_slot : Rosegold::Slot, amount : Int32) #

[View source]
def safe_take(source_slot_index : Int32, amount : Int32) #

[View source]
def same_item_same_components?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool #

[View source]
def send_click(slot_index : Int32, button : Int32, click_type) #

[View source]
def send_click(slot_index : Int32, operation : ClickOperation) #

[View source]
def send_click_if!(slot_index : Int32, operation : ClickOperation, session : Client::PlaySession, &authorized : -> Bool) : Bool #

Writes a click only if this menu, its content and session are still current under the write lock and authorized approves. Check the caller's authority and view revision in that block; it may run again after the click is built. Refused at once while another guarded menu write or an ordinary click is in progress, and if an ordinary click predicts before the write. A false result writes nothing. An IO failure disconnects and raises, and delivery may be unknown.


[View source]
def slots : Array(Rosegold::WindowSlot) #

[View source]
def slots=(new_slots : Array(Rosegold::WindowSlot)) #

[View source]
def slots_match?(slot1 : Rosegold::Slot, slot2 : Rosegold::Slot) : Bool #

[View source]
def state_id : UInt32 #

[View source]
def state_id=(state_id : UInt32) #

[View source]
def swap_hotbar(hotbar_nr, slot : Rosegold::WindowSlot) #

[View source]
def swap_hotbar(hotbar_nr, slot_number) #

[View source]
def to_s(io) #

[View source]
abstract def total_slots : Int32 #

[View source]
def update_all_slots(slots : Array(Rosegold::Slot), cursor : Rosegold::Slot, packet_state_id : UInt32) #

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

[View source]