class
Rosegold::ContainerHandle
- Rosegold::ContainerHandle
- Reference
- Object
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.crConstructors
-
.new(client : Rosegold::Client, menu : Rosegold::Menu)
Wraps an already-open menu.
Instance Method Summary
-
#as_anvil : AnvilMenu | Nil
Returns the menu as an anvil, or
nilwhen it is another type. -
#as_brewing_stand : BrewingStandMenu | Nil
Returns the menu as a brewing stand, or
nilwhen it is another type. -
#as_chest : ChestMenu | Nil
Returns the menu as a chest, or
nilwhen the open menu is another type. -
#as_crafting : CraftingMenu | Nil
Returns the menu as a crafting table, or
nilwhen it is another type. -
#as_enchantment : EnchantmentMenu | Nil
Returns the menu as an enchanting table, or
nilwhen it is another type. -
#as_furnace : FurnaceMenu | Nil
Returns the menu as a furnace, or
nilwhen it is another type. -
#as_hopper : HopperMenu | Nil
Returns the menu as a hopper, or
nilwhen it is another type. -
#as_merchant : MerchantMenu | Nil
Returns the menu as a merchant, or
nilwhen it is another type. -
#close
Closes the wrapped menu.
-
#count_in_container(spec) : Int32
Count matching items in the container.
-
#count_in_player(spec) : Int32
Count matching items in the player inventory.
-
#deposit(spec, count : Int32 = Int32::MAX) : Int32
Transfer items from player inventory to container via shift-click.
-
#drop(slot : Int32, full_stack : Bool = false)
Drop items from a slot.
-
#find_in_container(spec) : WindowSlot | Nil
Find the first slot matching spec in the container.
-
#find_in_inventory(spec) : WindowSlot | Nil
Find the first slot matching spec in the player inventory.
-
#menu : Menu
The active server menu wrapped by this handle.
-
#pickup(slot : Int32, count : Int32 = Int32::MAX)
Pick up items from a slot into the cursor.
-
#put_down(slot : Int32, count : Int32 = Int32::MAX)
Put down items from cursor into a slot.
-
#quick_move(slot : Int32)
Shift-click a slot (moves items between container and player inventory).
-
#swap_with_hotbar(slot : Int32, hotbar_slot : Int32)
Swap a slot with a hotbar slot (number keys 1-9).
-
#swap_with_offhand(slot : Int32)
Swap a slot with the offhand (F key).
-
#withdraw(spec, count : Int32 = Int32::MAX) : Int32
Transfer items from container to player inventory via shift-click.
Constructor Detail
Instance Method Detail
Returns the menu as an anvil, or nil when it is another type.
Returns the menu as a brewing stand, or nil when it is another type.
Returns the menu as a chest, or nil when the open menu is another type.
Returns the menu as a crafting table, or nil when it is another type.
Returns the menu as an enchanting table, or nil when it is another type.
Returns the menu as a merchant, or nil when it is another type.
Closes the wrapped menu. It queues the close packet without waiting for a later player-inventory update.
Transfer items from player inventory to container via shift-click. Stops once at least count items have moved, or no progress is possible. Whole stacks are shift-clicked, so the result may exceed count. Returns the item-count change observed in the local menu, not a server acknowledgment.
Find the first slot matching spec in the container.
Find the first slot matching spec in the player inventory.
Pick up items from a slot into the cursor. Uses left-click for full stack, right-click for half.
Put down items from cursor into a slot. Left-click places all, right-click places one.
Shift-click a slot (moves items between container and player inventory).
Swap a slot with a hotbar slot (number keys 1-9).
Transfer items from container to player inventory via shift-click. Stops once at least count items have moved, or no progress is possible. Whole stacks are shift-clicked, so the result may exceed count. Returns the item-count change observed in the local menu, not a server acknowledgment.