Class PrivItem

java.lang.Object
privbot.wrappers.PrivItem

public final class PrivItem extends Object
Inventory/bank/equipment slot wrapper; interactions route through the game client.
  • Method Details

    • getContainerKind

      public ItemContainerKind getContainerKind()
      The container this row came from.
    • getId

      public int getId()
      The item id in this slot as captured by the snapshot.
    • getQuantity

      public int getQuantity()
      The stack size in this slot as captured by the snapshot.
    • getAmount

      public int getAmount()
      Alias for getQuantity().
    • getItem

      public int getItem()
      Item id (for bank/equipment/inventory); same as getId().
    • getSlot

      public int getSlot()
      The 0-based slot index in its container.
    • getName

      public String getName()
      Resolves this item's display name via ItemManager.

      itemManager.getItemComposition(...) is a RuneLite client-thread API, and ctx.inventory.* runs on a script/worker thread — so this must marshal through GameThread.ensure(java.util.function.Supplier<T>, T) exactly like interact(String) does. Previously it called the API straight from the caller's thread inside a catch (Throwable ignored), which turned an off-thread failure into a plausible-looking wrong answer: confirmed live on Elorin where the item IS found (RESOLVED Inventory via direct-array widget (Strategy 0) -> 3214: 1 items) and the definition DOES resolve (ItemDefDiag id=385 resolved=true ... accessorName(ItemComp)=Shark), yet the name came back "item:385" — silently breaking every name-based verb (has, contains, count, outOf, first, eat, drink, wield, drop, use, ...) because ItemQuery.withName does "item:385".contains("shark") -> false.

      When ItemManager yields nothing usable — including when it is null, which is the normal case on Impact, Elorin and SpawnPK — this falls back to the client's item-name lookup, the same client-native definition-table route that the diagnostic above proved resolves Shark correctly. Only if BOTH paths come back empty does this degrade to the "item:<id>" placeholder.

    • isNoted

      public boolean isNoted()
      True when the item definition marks this id as a bank note. False when it cannot tell: with no ItemManager (Impact, Elorin, SpawnPK) this is always false. The lookup is not marshalled.
    • exists

      public boolean exists()
      True if this slot still holds the same item id and quantity in the live container snapshot from the client. Bank items return false when the bank is closed.
    • hasAction

      public boolean hasAction(String action)
      Whether the item definition lists action (exact, case-insensitive) among its inventory options. False when the definition cannot be read, which is not proof the option is missing.
    • interact

      public boolean interact(String action)
      Dispatches action on this slot, marshalled through GameThread.ensure(java.util.function.Supplier<T>, T). The slot index and id come from the snapshot, so act on a fresh query.
      Parameters:
      action - case-insensitive action label (e.g. Eat, Drop, Wear, Withdraw-1, Remove)
      Returns:
      true when the action was dispatched, not proof it happened: confirm the change (count, worn item, hitpoints) with a later read. False when the action cannot be resolved for this item or container, or the marshalled call was dropped.
    • eat

      public boolean eat()
      Eats this inventory item using its Eat menu option.
    • drink

      public boolean drink()
      Drinks this inventory item using its Drink menu option.