Skip to main content

Inventory And Item Actions

InventoryActions, BankInventoryActions, and UseItemActions provide result-aware wrappers around item widgets and item-on-target packets. They return InteractionResult to provide execution context rather than boolean values.

Read-only item metadata and ID mappings query IdMapRegistry (replacing legacy Python/wiki scraping). See Item Info And Prices for metadata reads. Keep this page focused on inventory, bank-inventory, item-on-target, and drop actions.

Inventory actions:

  • InventoryActions.use(name, actions...)
  • InventoryActions.use(id, actions...)
  • InventoryActions.use(Set<Integer>, actions...)
  • InventoryActions.use(predicate, actions...)
  • InventoryActions.useIndex(index, actions...)
  • InventoryActions.useSelectedSpell(id) - clicks an item while a spell remains selected
  • InventoryActions.moveSlot(fromSlot, toSlot) - moves an item between exact 0-based inventory slots with the paced, fail-closed widget-drag packet

moveSlot resolves dynamic inventory children, including an empty destination, and returns InteractionResult. Invalid indices, an unavailable/hidden inventory, an empty source, pacing, or an unhealthy packet mapping return a failure or paced wait without reporting the slot change as confirmed. Observe the inventory container on a later tick before advancing a multi-move layout workflow.

Use InventoryQuery for contains, count, and free-slot reads; see Query Helpers.

Inventory drop helpers:

  • InventoryDropPattern.rowMajor()
  • InventoryDropPattern.reverseRowMajor()
  • InventoryDropPattern.columnMajor()
  • InventoryDropPattern.reverseColumnMajor()
  • InventoryDropPattern.of(comparator)
  • InventoryDropActions.dropNext(predicate)
  • InventoryDropActions.dropNext(pattern, predicate)
  • InventoryDropActions.dropNext(pattern, items)

InventoryDropActions drops at most one item per call and returns an InteractionResult. Call it once from a tick/workflow step, inspect the result, and re-evaluate the inventory on the next tick. It avoids bulk-clicking an entire inventory in one call.

InteractionResult result = InventoryDropActions.dropNext(
InventoryDropPattern.columnMajor(),
widget -> widget.getItemId() == ItemID.OAK_LOGS);

if (result.getStatus() == InteractionStatus.PACED) {
return; // try again next tick
}

Bank inventory actions:

  • BankInventoryActions.use(name, actions...)
  • BankInventoryActions.use(id, actions...)
  • BankInventoryActions.use(predicate, actions...)
  • BankInventoryActions.useIndex(index, actions...)

Item-on-target actions:

All requested inventory interactions, drops, slot moves, item-on-target operations, widget-on-widget operations, and inventory drags require the Inventory tab to be visible. A closed tab returns WIDGET_HIDDEN targeting tab/INVENTORY before any dependent click, menu action, or packet is queued. Call TabActions.open(Tab.INVENTORY) explicitly and observe TabActions.isOpen(...) before retrying.

  • UseItemActions.itemOnItem(sourceName, targetName) - name-based; returns TARGET_NULL if either name evaluates null, TARGET_NOT_FOUND if either item remains absent
  • UseItemActions.itemOnItem(sourceItemId, targetItemId)
  • UseItemActions.itemOnNpc(sourceItemId, npcName)
  • UseItemActions.itemOnObject(sourceItemId, objectName)
  • UseItemActions.itemOnTileItem(sourceItemId, tileItemId)
  • UseItemActions.widgetOnWidget(source, target)
  • UseItemActions.itemOnPlayer(itemId, playerName) - resolves the player by name via Players.search() then delegates to the Player overload
  • UseItemActions.itemOnPlayer(itemId, Player) - queues PlayerPackets.queueWidgetOnPlayer; returns TARGET_NULL if player evaluates null, TARGET_NOT_FOUND if item remains outside inventory
  • UseItemActions.dragAndDrop(src, dest) - queues WidgetPackets.queueDragAndDrop; returns WIDGET_HIDDEN if either widget stays hidden, TARGET_NULL if either evaluates null, and PACKET_NOT_QUEUED when the mapped packet refuses to send

Example:

InteractionResult result = UseItemActions.itemOnNpc(995, "Banker");
if (result.failed() && result.getStatus() != InteractionStatus.PACED) {
log.debug("Use item failed: {}", result.getMessage());
}