class

Rosegold::ContainerHandle

Inherits Reference / Object

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.

Constructors

Instance methods

as_anvil
Source
as_brewing_stand
Source
as_chest

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

Source
as_crafting
Source
as_enchantment
Source
as_furnace
Source
as_hopper
Source
as_merchant
Source
close
Source
count_in_container(spec) : Int32

Count matching items in the container.

Source
count_in_player(spec) : Int32

Count matching items in the player inventory.

Source
deposit(spec, count : Int32 = Int32::MAX) : Int32

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

Source
drop(slot : Int32, full_stack : Bool = false)

Drop items from a slot.

Source
find_in_container(spec) : WindowSlot | Nil

Find the first slot matching spec in the container.

Source
find_in_inventory(spec) : WindowSlot | Nil

Find the first slot matching spec in the player inventory.

Source
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.

Source
put_down(slot : Int32, count : Int32 = Int32::MAX)

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

Source
quick_move(slot : Int32)

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

Source
swap_with_hotbar(slot : Int32, hotbar_slot : Int32)

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

Source
swap_with_offhand(slot : Int32)

Swap a slot with the offhand (F key).

Source
withdraw(spec, count : Int32 = Int32::MAX) : Int32

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

Source