class Rosegold::ContainerHandle

Overview

User-facing handle for interacting with an open container. Wraps a Menu and provides intent-level operations (withdraw, deposit) as well as item-level operations (pickup, put_down, move, swap). Auto-closes via ensure when used with a block.

Defined in:

rosegold/inventory/container_handle.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Rosegold::Client, menu : Rosegold::Menu) #

[View source]

Instance Method Detail

def as_anvil : AnvilMenu | Nil #

[View source]
def as_brewing_stand : BrewingStandMenu | Nil #

[View source]
def as_chest : ChestMenu | Nil #

Returns the menu as a specific type, or nil if it doesn't match.


[View source]
def as_crafting : CraftingMenu | Nil #

[View source]
def as_enchantment : EnchantmentMenu | Nil #

[View source]
def as_furnace : FurnaceMenu | Nil #

[View source]
def as_hopper : HopperMenu | Nil #

[View source]
def as_merchant : MerchantMenu | Nil #

[View source]
def close #

[View source]
def count_in_container(spec) : Int32 #

Count matching items in the container.


[View source]
def count_in_player(spec) : Int32 #

Count matching items in the player inventory.


[View source]
def deposit(spec, count : Int32 = Int32::MAX) : Int32 #

Transfer items from player inventory to container via shift-click. Returns the number of items actually transferred.


[View source]
def drop(slot : Int32, full_stack : Bool = false) #

Drop items from a slot.


[View source]
def find_in_container(spec) : WindowSlot | Nil #

Find the first slot matching spec in the container.


[View source]
def find_in_inventory(spec) : WindowSlot | Nil #

Find the first slot matching spec in the player inventory.


[View source]
def menu : Menu #

[View source]
def pickup(slot : Int32, count : Int32 = Int32::MAX) #

Pick up items from a slot into the cursor. Uses left-click for full stack, right-click for half.


[View source]
def put_down(slot : Int32, count : Int32 = Int32::MAX) #

Put down items from cursor into a slot. Left-click places all, right-click places one.


[View source]
def quick_move(slot : Int32) #

Shift-click a slot (moves items between container and player inventory).


[View source]
def swap_with_hotbar(slot : Int32, hotbar_slot : Int32) #

Swap a slot with a hotbar slot (number keys 1-9).


[View source]
def swap_with_offhand(slot : Int32) #

Swap a slot with the offhand (F key).


[View source]
def withdraw(spec, count : Int32 = Int32::MAX) : Int32 #

Transfer items from container to player inventory via shift-click. Returns the number of items actually transferred.


[View source]