Class NPCQuery
java.lang.Object
privbot.query.NPCQuery
Fluent filter chain over the NPCs in the scene, built by
ctx.npcs.query().
The hook takes the NPC list on the client thread; the chain then runs on the caller's
thread. Filters narrow the query in place, so a query is single-use. Native name, action and position reads marshal through GameThread.ensure(java.util.function.Supplier<T>, T);
custom filter predicates retain their caller-thread contract. An empty result can mean
"nothing matches" or "the scene could not be read"; check ctx.game.isLoggedIn() before
acting on an absence.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalive()Excludes dead NPCs usingPrivNPC.isAlive().closest()The NPC nearest the local player in tile steps.Filter then nearest to the local player.booleanempty()True when no entry is left.Keeps NPCs that are NOT the hint arrow target (inverse ofhintArrowOnly()).Narrows this query in place and returns it.first()The first remaining entry in snapshot order, or null when the query is empty.Narrows bypred(in place) and returns the first match, or null.Keeps only the NPC that is the current hint arrow target.list()An unmodifiable view of the remaining entries.nearest()Alias ofclosest().Alias ofclosest(Predicate).Keeps NPCs the local player stands east of (player X > NPC X).Keeps NPCs whose tile the local player stands strictly north of (player Y > NPC Y, same plane).Keeps NPCs the local player stands south of (player Y < NPC Y).Keeps NPCs the local player stands west of (player X < NPC X).intsize()The number of entries left.Alias offilter(Predicate).withAction(String... actions) Keeps NPCs whose composition has at least one of the given actions (case-insensitive substring).withId(int... ids) Keeps NPCs whose composition id is one ofids; no ids leaves the query unchanged.withinTiles(int maxTiles) Chebyshev distance on the current plane (OSRS tile steps).Keeps NPCs whose name contains any ofnames(case-insensitive substring, tags stripped).
-
Constructor Details
-
NPCQuery
-
-
Method Details
-
withId
Keeps NPCs whose composition id is one ofids; no ids leaves the query unchanged. -
withAction
-
withName
-
filter
-
where
Alias offilter(Predicate). -
alive
Excludes dead NPCs usingPrivNPC.isAlive(). -
withinTiles
Chebyshev distance on the current plane (OSRS tile steps). Leaves the query unchanged when the local player's position cannot be read ormaxTilesis negative. -
playerNorthOf
Keeps NPCs whose tile the local player stands strictly north of (player Y > NPC Y, same plane). SeePlayerRelativeToPoint. -
playerSouthOf
Keeps NPCs the local player stands south of (player Y < NPC Y). -
playerWestOf
Keeps NPCs the local player stands west of (player X < NPC X). -
playerEastOf
Keeps NPCs the local player stands east of (player X > NPC X). -
hintArrowOnly
Keeps only the NPC that is the current hint arrow target. -
excludeHintArrow
Keeps NPCs that are NOT the hint arrow target (inverse ofhintArrowOnly()). -
closest
The NPC nearest the local player in tile steps. NPCs on another plane rank last. When the player's position cannot be read this returns the first entry instead; null when empty. -
closest
-
nearest
-
nearest
Alias ofclosest(Predicate). -
first
The first remaining entry in snapshot order, or null when the query is empty. -
first
-
list
-
empty
public boolean empty()True when no entry is left. -
size
public int size()The number of entries left.
-