Class Inventory
java.lang.Object
privbot.hooks.Inventory
Inventory hook backed by the client's inventory snapshots.
For multi-step eat flows (query Eat, name patterns, id fallback), see InventoryFoodQueries.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int... ids) booleanintcount(int id) intTotal quantity of items whose display name equalsname(case-insensitive), e.g.static intcountAll(int id) Static count that needs noctx; preferctx.inventory.count(id).static intStatic count that needs noctx; preferctx.inventory.count(name).booleanDrinks the first inventory item matching any supplied name.booleandrinkFirst(String... names) Drinks the first inventory item matching any supplied name.booleanDrops the first inventory item matching any supplied name.voidDrops every carried item matchingnames, one dispatch per slot.voiddropAllExcept(int... keepIds) Drops every carried item whose id is not inkeepIds; does nothing for an empty keep list.voiddropAllExcept(String... keepNames) Drops every carried item whose name is not inkeepNames; does nothing for an empty keep list.voidDrops every carried item, keeping nothing.booleanEats the first inventory item matching any supplied name.booleanEats the first inventory item matching any supplied name.booleaneatFood()Eats the first inventory item with anEataction.intCount of unoccupied inventory slots (max 28).static PrivItemStatic lookup that needs noctx; preferctx.inventory.get(pred).First inventory item matching any supplied name, ornull.Same asget(Predicate); Scar-style name.food()First inventory item with anEataction, ornull.static booleanfull()Static read that needs noctx; preferctx.inventory.isFull().First inventory slot matchingpred, or null.net.runelite.api.ItemContainerReturns the raw inventoryItemContainer.net.runelite.api.ItemContainerReturns the raw equipmentItemContainer.booleanTrue when inventory holds at least one item whose display name matchesname(case-insensitive contains, same semantics ascontains(String...)).booleanhasFood()Whether inventory holds at least one item with anEataction.booleanInteracts with the first item matchingnameusingaction.booleaninteract(ItemContainerSnapshot.Item selected, String action) Interact with a detached selection after confirming the slot still holds that item and action.booleanisEmpty()booleanisFull()booleanTrue when inventory holds no item matchingname.query()A fresh query over the carried items (one read per call).snapshot()Detached facts captured in one client callback.booleanUses the first inventory item matching any supplied name.booleanUses the first inventory item matchingsourceNameon the first item matchingtargetName(select then use-on-widget).booleanuseOnObject(String itemName, PrivObject object) Uses the first inventory item matchingitemNameonobject: select the item ("Use"), then use it on the object, the same two clicks a player makes (Elorin: op 447, then op 62 on the object's scene tag).booleanWields or wears the first inventory item matching any supplied name.
-
Method Details
-
snapshot
Detached facts captured in one client callback. A supplied client's item container is the source of truth; missing data returns available=false. Adapter-only instances use adapter rows. Repeated calls insidectx.read(...)reuse the same observation. -
interact
Interact with a detached selection after confirming the slot still holds that item and action. Delegates dispatch to the existing PrivItem/adapter mapping. True means accepted, not completed. -
query
A fresh query over the carried items (one read per call).- Returns:
- the query
-
getContainer
public net.runelite.api.ItemContainer getContainer()Returns the raw inventoryItemContainer. Preferquery(); this exists so callers can replace directclient.getItemContainer(INVENTORY)without rewriting inlineItemContaineriteration logic. -
getEquipmentContainer
public net.runelite.api.ItemContainer getEquipmentContainer()Returns the raw equipmentItemContainer. Preferctx.equipmentaccessors; this exists for legacy drop-in replacement ofclient.getItemContainer(EQUIPMENT). -
contains
public boolean contains(int... ids) - Parameters:
ids- item ids- Returns:
- whether any carried item has one of
ids
-
contains
- Parameters:
names- item names (matched asItemQuery.withName(java.lang.String...)does)- Returns:
- whether any carried item matches
-
count
public int count(int id) - Parameters:
id- an item id- Returns:
- the total quantity carried with that id
-
count
Total quantity of items whose display name equalsname(case-insensitive), e.g. forInventory.count(food.getName())patterns. -
has
True when inventory holds at least one item whose display name matchesname(case-insensitive contains, same semantics ascontains(String...)). -
outOf
True when inventory holds no item matchingname. Inverse ofhas(String). -
get
-
first
Same asget(Predicate); Scar-style name. -
first
-
hasFood
public boolean hasFood()Whether inventory holds at least one item with anEataction. -
food
First inventory item with anEataction, ornull. -
eatFood
public boolean eatFood()Eats the first inventory item with anEataction. -
eatFirst
Eats the first inventory item matching any supplied name. -
eat
Eats the first inventory item matching any supplied name. -
drinkFirst
Drinks the first inventory item matching any supplied name. -
drink
Drinks the first inventory item matching any supplied name. -
interact
-
drop
Drops the first inventory item matching any supplied name. -
wield
Wields or wears the first inventory item matching any supplied name. -
use
Uses the first inventory item matching any supplied name. -
useOn
-
useOnObject
Uses the first inventory item matchingitemNameonobject: select the item ("Use"), then use it on the object, the same two clicks a player makes (Elorin: op 447, then op 62 on the object's scene tag).interact("Use")is NOT this: it maps to the item's first option, so bones were buried instead of offered (2026-10-18). Objects have no literal "Use" action either, so the second click cannot beobject.interact("Use"). -
emptySlots
public int emptySlots()Count of unoccupied inventory slots (max 28). -
isFull
public boolean isFull()- Returns:
- whether all 28 slots hold an item (false also when the inventory cannot be read)
-
isEmpty
public boolean isEmpty()- Returns:
- whether nothing is carried (also true when unreadable: use
snapshot()to tell apart)
-
dropAll
Drops every carried item matchingnames, one dispatch per slot.- Parameters:
names- item names
-
dropEverything
public void dropEverything()Drops every carried item, keeping nothing.Deliberately separate from
dropAllExcept(String...), which returns without dropping anything when handed an empty keep list — a safety net for callers that build the list dynamically. "Drop everything" therefore has to be asked for by name, so it can never be the accidental result of an empty parameter. -
dropAllExcept
public void dropAllExcept(int... keepIds) Drops every carried item whose id is not inkeepIds; does nothing for an empty keep list.- Parameters:
keepIds- item ids to keep
-
dropAllExcept
Drops every carried item whose name is not inkeepNames; does nothing for an empty keep list.- Parameters:
keepNames- item names to keep
-
full
public static boolean full()Static read that needs noctx; preferctx.inventory.isFull().- Returns:
- whether the inventory is full
-
find
-
countAll
public static int countAll(int id) Static count that needs noctx; preferctx.inventory.count(id).- Parameters:
id- an item id- Returns:
- the total quantity carried
-
countAll
Static count that needs noctx; preferctx.inventory.count(name).- Parameters:
exactName- the exact item name- Returns:
- the total quantity carried
-