Class Loot

java.lang.Object
privbot.hooks.Loot

public final class Loot extends Object
Picks up the drops a LootSpec wants, one proved item per step: ctx.loot.

What it proves: a pick counts only when the carried count of that item rose after the Take (waits up to 2400 ms per pick). A stackable already carried is proved by its quantity rising, never by a slot filling. A drop whose count did not rise three times (same id and tile) is given up on for the rest of the job. When the only wanted drops left in range are ones it gave up on, the job ends FAILED with "gave up on N drop(s) that did not arrive", not DONE: they are still there. A full inventory ends the job DONE ("inventory full") and stops clicking, unless the nearest wanted drop is a stackable already carried.

Unreadable looks like: an unreadable inventory is never "nothing left". The job stays RUNNING with reason "inventory unreadable" and fails after 5 such steps in a row (an unreadable read after a Take's wait counts there, not against the drop). If the ground cannot be scanned at all (the client has no ground-item API) the job ends UNSUPPORTED, "ground items unreadable": that is permanent for the client, so it is final rather than a FAILED that invites a retry. "Nothing left" (DONE) means the scan ran and found no wanted drop in range, given up on or not.

Thread rule: call Job.step(privbot.task.PrivTaskContext) from a node on the script worker; the reads marshal themselves and the proof wait uses PrivTaskContext.sleepUntil(java.util.function.BooleanSupplier, int). The job object is not thread-safe: keep it in the plugin's state and step it from one thread. Job.cancel() may come from another thread (Stop): it ends the job FAILED "cancelled" and no later step clicks.

  • Method Details

    • collect

      public Job collect(LootSpec spec)
      Starts a job that collects what spec wants. Step it once per tick; each step is at most one pick.
      Parameters:
      spec - what to take, how far to look and the most picks
      Returns:
      a new job, RUNNING