Skip to main content

Inventory And Item Actions

InventoryActions, BankInventoryActions, and UseItemActions provide result-aware wrappers around item widgets and item-on-target packets.

Read-only item metadata and OSRS Wiki price quotes live in Item Info And Prices. 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 is already selected

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 deliberately does not bulk-click 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:

  • UseItemActions.itemOnItem(sourceName, targetName) - name-based; returns TARGET_NULL if either name is null, TARGET_NOT_FOUND if either item is 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 is null, TARGET_NOT_FOUND if item not in inventory
  • UseItemActions.dragAndDrop(src, dest) - queues WidgetPackets.queueDragAndDrop; returns WIDGET_HIDDEN if either widget is hidden, TARGET_NULL if either is null

Example:

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

Legacy compatibility:

InventoryInteraction and BankInventoryInteraction remain available for old boolean-returning call sites.