Looting Bag Actions
LootingBagActions provides a result-aware API for interacting with the looting bag inventory widget. It supports both queries and item deposits.
Core Methods
isOpen(): Checks if the looting bag container widget stays active.getAll(Predicate<Widget>)/getFirst(Predicate<Widget>): Queries visible contents within the looting bag.contains(int itemId)/count(int itemId): Helper methods to check item presence and quantify amounts.open(): Attempts to open a standard looting bag from the inventory. Returns anInteractionResult.deposit(int itemId, int amount)/deposit(Predicate<Widget>, int amount): Dispatches inventory deposit actions after validating the requested amount. Returns anInteractionResult.
Implementation Notes:
- Deposit methods require a valid game and client inventory state.
- The implementation operates exclusively at the widget and action level. It avoids inferring or managing Wilderness-specific rules.
Inspecting Contents
You must open the looting bag before querying its contents. Methods like contains and count read the active widget state and never open the bag implicitly.
if (!LootingBagActions.isOpen()) {
InteractionResult open = LootingBagActions.open();
if (open.failed()) {
log.debug("Could not open looting bag: {}", open.getMessage());
return;
}
}
int natureRunes = LootingBagActions.count(561);
if (natureRunes < 100) {
log.debug("Need more nature runes in the looting bag");
}
Depositing by Item ID
When you know the precise item ID, use the specific deposit helper.
InteractionResult result = LootingBagActions.deposit(561, 10);
if (result.failed()) {
log.debug("Looting bag deposit failed: {}", result.getMessage());
}
Depositing by Predicate
Predicate-based deposits work best when item IDs vary but the widget characteristics remain sufficient for identification.
InteractionResult result = LootingBagActions.deposit(
widget -> widget.getItemId() > 0 && widget.getItemQuantity() >= 100,
1
);