Class ObjectQuery
ctx.objects.query().
Name, action and player-relative filters and closest() read object definitions and
the player position, so off the client thread they re-run inside GameThread.ensure(java.util.function.Supplier<T>, T) on a
copy and return that copy. If that read is dropped they return null, so a long chain from
a worker can throw; split the chain or wrap it in ctx.read(...). Filters narrow the
query in place, so a query is single-use.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectQuery(List<PrivObject> raw, net.runelite.api.Client client) Wraps a copy ofraw; plugins normally get a query fromctx.objects.query(). -
Method Summary
Modifier and TypeMethodDescriptionatTile(net.runelite.api.coords.WorldPoint tile) Keeps objects whose world location equalstile(same x, y, plane).closest()Closest by Euclidean distance to the local player.closest(Predicate<PrivObject> pred) Narrows bypred(in place), then returns the closest match; seeclosest().booleanempty()True when no entry is left.filter(Predicate<PrivObject> pred) Narrows this query in place and returns it.first()The first remaining entry in snapshot order, or null when the query is empty.first(Predicate<PrivObject> pred) Narrows bypred(in place) and returns the first match, or null.list()An unmodifiable view of the remaining entries.nearest()Alias ofclosest().nearest(Predicate<PrivObject> pred) Alias ofclosest(Predicate).nearTile(net.runelite.api.coords.WorldPoint tile, int radius) Chebyshev radius aroundtileon the same plane.Keeps objects the local player stands east of (player X > object X).Keeps objects whose tile the local player stands strictly north of (player Y > object Y, same plane).Keeps objects the local player stands south of (player Y < object Y).Keeps objects the local player stands west of (player X < object X).intsize()The number of entries left.where(Predicate<PrivObject> pred) Alias offilter(Predicate).withAction(String... actions) Keeps objects whose definition has at least one of the given actions (case-insensitive substring).withId(int... ids) Keeps objects whose scene id is one ofids; no ids leaves the query unchanged.withinTiles(int maxTiles) Chebyshev distance on the current plane (OSRS tile steps).Name substring match (seePrivObject.getName()).
-
Constructor Details
-
ObjectQuery
Wraps a copy ofraw; plugins normally get a query fromctx.objects.query().
-
-
Method Details
-
withAction
Keeps objects whose definition has at least one of the given actions (case-insensitive substring).Runs composition/action resolution on the game thread when the caller is not on the client thread (e.g. script executor), matching
behaviour.invalid reference
GameObjects#query() -
withName
Name substring match (seePrivObject.getName()).Must run on the game thread because filtering calls
getObjectDefinitionviaPrivObject.getName(). -
withId
Keeps objects whose scene id is one ofids; no ids leaves the query unchanged. -
withinTiles
Chebyshev distance on the current plane (OSRS tile steps). Same contract asNPCQuery.withinTiles(int). -
atTile
Keeps objects whose world location equalstile(same x, y, plane). Null tile → empty. -
nearTile
Chebyshev radius aroundtileon the same plane. Null tile or radius < 0 → empty. -
filter
Narrows this query in place and returns it. Queries are mutable and single-use; the predicate runs on the calling thread. -
where
Alias offilter(Predicate). -
playerNorthOf
Keeps objects whose tile the local player stands strictly north of (player Y > object Y, same plane). SeePlayerRelativeToPoint. -
playerSouthOf
Keeps objects the local player stands south of (player Y < object Y). -
playerWestOf
Keeps objects the local player stands west of (player X < object X). -
playerEastOf
Keeps objects the local player stands east of (player X > object X). -
closest
Closest by Euclidean distance to the local player. Requires client thread for player location.The distance is
PrivObject.distanceTo(net.runelite.api.coords.WorldPoint), which is the tile-step (Chebyshev) distance and ignores the plane. Marshals throughGameThread.ensure(java.util.function.Supplier<T>, T)off the client thread and returns null when that read is dropped; returns the first entry when the player position cannot be read; null when empty. -
closest
Narrows bypred(in place), then returns the closest match; seeclosest(). -
nearest
Alias ofclosest(). -
nearest
Alias ofclosest(Predicate). -
first
The first remaining entry in snapshot order, or null when the query is empty. -
first
Narrows bypred(in place) and returns the first match, or null. -
list
An unmodifiable view of the remaining entries. -
empty
public boolean empty()True when no entry is left. -
size
public int size()The number of entries left.
-