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 selectedInventoryActions.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; returnsTARGET_NULLif either name evaluates null,TARGET_NOT_FOUNDif either item remains absentUseItemActions.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 viaPlayers.search()then delegates to thePlayeroverloadUseItemActions.itemOnPlayer(itemId, Player)- queuesPlayerPackets.queueWidgetOnPlayer; returnsTARGET_NULLif player evaluates null,TARGET_NOT_FOUNDif item remains outside inventoryUseItemActions.dragAndDrop(src, dest)- queuesWidgetPackets.queueDragAndDrop; returnsWIDGET_HIDDENif either widget stays hidden,TARGET_NULLif either evaluates null, andPACKET_NOT_QUEUEDwhen 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());
}