EntityQuery
A query class to filter and sort locatable, identifiable and interactable entities in the game world.
ClassRLPlugins API
public class EntityQuery extends AbstractQuery<Entity, EntityQuery>Members
Constructors
- newEntityQuery()
Creates a EntityQuery.
Methods
- EntityQuerybeyondDistance(int)
Filters the query results to only include entities beyond the specified distance from the local player.
- Entityfarthest()
Get the farthest entity from the filtered list Terminal operation - executes the query.
- Entityfarthest(WorldPoint)
Get the farthest entity from a specific point Terminal operation - executes the query.
- EntitylongestPath()
Get the entity with the longest path from the filtered list Terminal operation - executes the query.
- Entitynearest()
Get the nearest entity from the filtered list Terminal operation - executes the query.
- Entitynearest(WorldPoint)
Get the nearest entity to a specific point Terminal operation - executes the query.
- EntityQueryofTypes(Class<? extends Entity>...)
Filters the query results to only include locatable interactables of the specified types.
- EntityQueryremoveNpcs()
Filters the query results to exclude NPCs.
- EntityQueryremovePlayers()
Filters the query results to exclude players.
- EntityQueryremoveTileItems()
Filters the query results to exclude tile items.
- EntityQueryremoveTileObjects()
Filters the query results to exclude tile objects.
- EntityshortestPath()
Get the entity with the shortest path from the filtered list Terminal operation - executes the query.
- EntityQuerysortFurthest()
Sorts the query results by distance from the local player, furthest first.
- EntityQuerysortFurthest(WorldPoint)
Sorts the query results by distance from the specified center point, furthest first.
- EntityQuerysortLongestPath()
Sort by longest path from the player.
- EntityQuerysortLongestPath(WorldPoint)
Sort by longest path from a specific point.
- EntityQuerysortNearest()
Sorts the query results by distance from the local player, nearest first.
- EntityQuerysortNearest(WorldPoint)
Sorts the query results by distance from the specified center point, nearest first.
- EntityQuerysortShortestPath()
Sort by shortest path from the player.
- EntityQuerysortShortestPath(WorldPoint)
Sort by shortest path from a specific point.
- EntityQuerywithAction(String)
Filters the query results to only include entities with the specified action.
- EntityQuerywithId(int...)
Filters the query to only include entities with the specified IDs.
- EntityQuerywithinDistance(int)
Filters the query results to only include entities within the specified distance from the local player.
- EntityQuerywithName(String)
Filters the query to only include entities with the specified name.
- EntityQuerywithNameContains(String)
Filters the query to only include entities with names that contain the specified string.
- EntityQuerywithNameMatches(String)
Filters the query to only include entities with names that match the specified wildcard pattern.
- EntityQuerywithNames(String...)
Filters the query to only include entities with the specified names.
- EntityQuerywithNamesContains(String...)
Filters the query to only include entities with names that contain any of the specified strings.
- EntityQuerywithPartialAction(String)
Filters the query results to only include entities with an action that partially matches the specified string.
Inherited from AbstractQuery
- Raggregate(Function<Stream<Entity>, R>)
Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
- booleanall(Predicate<Entity>)
Check if all filtered results match the predicate.
- booleanany(Predicate<Entity>)
Check if any filtered result matches the predicate.
- List<Entity>collect()
Get the filtered/sorted list.
- Rcollect(Collector<Entity, ?, R>)
Execute filters and process with custom collector.
- intcount()
Get count of filtered results.
- EntityQuerydistinct()
Ensure results are distinct.
- Entityfirst()
Get the first element from the filtered/sorted list.
- voidfirstIfPresent(Consumer<Entity>)
First if present.
- voidfirstOrElse(Consumer<Entity>, Runnable)
Perform action on the first element, or else run elseAction if no results.
- voidforEach(Consumer<Entity>)
Executes filters and performs an action on each result.
- booleanisEmpty()
Check if there are no filtered results.
- EntityQuerykeepIf(Predicate<Entity>)
Lazily filter by predicate (keeps matching items).
- Entitylast()
Get the last element from the filtered/sorted list.
- voidlastOrElse(Consumer<Entity>, Runnable)
Perform action on the last element, or else run elseAction if no results.
- EntityQuerylimit(int)
Limit the number of results.
- booleannone(Predicate<Entity>)
Check if no filtered results match the predicate.
- EntityQuerypeek(Consumer<Entity>)
Peek at each element during processing.
- EntityQuerypostProcess(Function<List<Entity>, List<Entity>>)
Apply a post-processing function after sorting.
- Entityrandom()
Get a random element from the filtered/sorted list.
- EntityQueryremoveIf(Predicate<Entity>)
Lazily filter by predicate (removes matching items).
- EntityQueryskip(int)
Skip a number of results.
- EntityQuerysort(Comparator<Entity>)
Lazily add sorting.
EntityQuery()
public EntityQuery()Creates a EntityQuery.
beyondDistance(int)
public EntityQuery beyondDistance(int distance)Filters the query results to only include entities beyond the specified distance from the local player.
Parameters
distance- The distance threshold.
Returns
EntityQuery.
farthest()
public Entity farthest()Get the farthest entity from the filtered list Terminal operation - executes the query.
farthest(WorldPoint)
public Entity farthest(WorldPoint center)Get the farthest entity from a specific point Terminal operation - executes the query.
Parameters
center- Center.
longestPath()
public Entity longestPath()Get the entity with the longest path from the filtered list Terminal operation - executes the query.
nearest()
public Entity nearest()Get the nearest entity from the filtered list Terminal operation - executes the query.
nearest(WorldPoint)
public Entity nearest(WorldPoint center)Get the nearest entity to a specific point Terminal operation - executes the query.
Parameters
center- Center.
ofTypes(Class<? extends Entity>...)
public EntityQuery ofTypes(Class<? extends Entity>... types)Filters the query results to only include locatable interactables of the specified types.
Parameters
types- The classes of locatable interactables to include.
Returns
LocatableInteractableQuery.
removeNpcs()
public EntityQuery removeNpcs()Filters the query results to exclude NPCs.
Returns
EntityQuery.
removePlayers()
public EntityQuery removePlayers()Filters the query results to exclude players.
Returns
EntityQuery.
removeTileItems()
public EntityQuery removeTileItems()Filters the query results to exclude tile items.
Returns
EntityQuery.
removeTileObjects()
public EntityQuery removeTileObjects()Filters the query results to exclude tile objects.
Returns
EntityQuery.
shortestPath()
public Entity shortestPath()Get the entity with the shortest path from the filtered list Terminal operation - executes the query.
sortFurthest()
public EntityQuery sortFurthest()Sorts the query results by distance from the local player, furthest first.
Returns
EntityQuery.
sortFurthest(WorldPoint)
public EntityQuery sortFurthest(WorldPoint center)Sorts the query results by distance from the specified center point, furthest first.
Parameters
center- The center point to measure distance from.
Returns
EntityQuery.
sortLongestPath()
public EntityQuery sortLongestPath()Sort by longest path from the player.
Returns
EntityQuery.
sortLongestPath(WorldPoint)
public EntityQuery sortLongestPath(WorldPoint center)Sort by longest path from a specific point.
Parameters
center- Center point.
Returns
EntityQuery.
sortNearest()
public EntityQuery sortNearest()Sorts the query results by distance from the local player, nearest first.
Returns
EntityQuery.
sortNearest(WorldPoint)
public EntityQuery sortNearest(WorldPoint center)Sorts the query results by distance from the specified center point, nearest first.
Parameters
center- The center point to measure distance from.
Returns
EntityQuery.
sortShortestPath()
public EntityQuery sortShortestPath()Sort by shortest path from the player.
Returns
EntityQuery.
sortShortestPath(WorldPoint)
public EntityQuery sortShortestPath(WorldPoint center)Sort by shortest path from a specific point.
Parameters
center- Center point.
Returns
EntityQuery.
withAction(String)
public EntityQuery withAction(String action)Filters the query results to only include entities with the specified action.
Parameters
action- The action to filter by.
Returns
EntityQuery.
withId(int...)
public EntityQuery withId(int... id)Filters the query to only include entities with the specified IDs.
Parameters
id- The IDs to filter by.
Returns
EntityQuery.
withinDistance(int)
public EntityQuery withinDistance(int distance)Filters the query results to only include entities within the specified distance from the local player.
Parameters
distance- The distance threshold.
Returns
EntityQuery.
withName(String)
public EntityQuery withName(String name)Filters the query to only include entities with the specified name.
Parameters
name- The name to filter by.
Returns
EntityQuery.
withNameContains(String)
public EntityQuery withNameContains(String name)Filters the query to only include entities with names that contain the specified string.
Parameters
name- The string to filter by.
Returns
EntityQuery.
withNameMatches(String)
public EntityQuery withNameMatches(String namePart)Filters the query to only include entities with names that match the specified wildcard pattern.
Parameters
namePart- The wildcard pattern to filter by.
Returns
EntityQuery.
withNames(String...)
public EntityQuery withNames(String... names)Filters the query to only include entities with the specified names.
Parameters
names- The names to filter by.
Returns
EntityQuery.
withNamesContains(String...)
public EntityQuery withNamesContains(String... names)Filters the query to only include entities with names that contain any of the specified strings.
Parameters
names- The strings to filter by.
Returns
EntityQuery.
withPartialAction(String)
public EntityQuery withPartialAction(String partial)Filters the query results to only include entities with an action that partially matches the specified string.
Parameters
partial- The partial action string to filter by.
Returns
EntityQuery.
aggregate(Function<Stream<Entity>, R>)from AbstractQuery
public R aggregate(Function<Stream<Entity>, R> aggregator)Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
Parameters
aggregator- Aggregator.
all(Predicate<Entity>)from AbstractQuery
public boolean all(Predicate<Entity> predicate)Check if all filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if all match, false otherwise.
any(Predicate<Entity>)from AbstractQuery
public boolean any(Predicate<Entity> predicate)Check if any filtered result matches the predicate.
Parameters
predicate- Predicate to test.
Returns
True if any match, false otherwise.
collect()from AbstractQuery
public List<Entity> collect()Get the filtered/sorted list.
collect(Collector<Entity, ?, R>)from AbstractQuery
public R collect(Collector<Entity, ?, R> collector)Execute filters and process with custom collector.
Parameters
collector- Collector.
count()from AbstractQuery
public int count()Get count of filtered results.
distinct()from AbstractQuery
public EntityQuery distinct()Ensure results are distinct.
Returns
The query instance.
first()from AbstractQuery
public Entity first()Get the first element from the filtered/sorted list.
firstIfPresent(Consumer<Entity>)from AbstractQuery
public void firstIfPresent(Consumer<Entity> action)First if present.
Parameters
action- Action.
firstOrElse(Consumer<Entity>, Runnable)from AbstractQuery
public void firstOrElse(Consumer<Entity> action, Runnable elseAction)Perform action on the first element, or else run elseAction if no results.
Parameters
action- Action to perform on the first element.
elseAction- Action to perform if no results.
forEach(Consumer<Entity>)from AbstractQuery
public void forEach(Consumer<Entity> action)Executes filters and performs an action on each result.
Parameters
action- Action.
isEmpty()from AbstractQuery
public boolean isEmpty()Check if there are no filtered results.
Returns
True if no results after filtering, false otherwise.
keepIf(Predicate<Entity>)from AbstractQuery
public EntityQuery keepIf(Predicate<Entity> predicate)Lazily filter by predicate (keeps matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
last()from AbstractQuery
public Entity last()Get the last element from the filtered/sorted list.
lastOrElse(Consumer<Entity>, Runnable)from AbstractQuery
public void lastOrElse(Consumer<Entity> action, Runnable elseAction)Perform action on the last element, or else run elseAction if no results.
Parameters
action- Action to perform on the last element.
elseAction- Action to perform if no results.
limit(int)from AbstractQuery
public EntityQuery limit(int maxSize)Limit the number of results.
Parameters
maxSize- Max size.
Returns
The query instance.
none(Predicate<Entity>)from AbstractQuery
public boolean none(Predicate<Entity> predicate)Check if no filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if none match, false otherwise.
peek(Consumer<Entity>)from AbstractQuery
public EntityQuery peek(Consumer<Entity> action)Peek at each element during processing.
Parameters
action- Action to perform on each element.
Returns
The query instance.
postProcess(Function<List<Entity>, List<Entity>>)from AbstractQuery
public EntityQuery postProcess(Function<List<Entity>, List<Entity>> processor)Apply a post-processing function after sorting.
Useful for reordering algorithms that can't be expressed as Comparators.
Parameters
processor- Function to transform the result list.
Returns
The query instance.
random()from AbstractQuery
public Entity random()Get a random element from the filtered/sorted list.
removeIf(Predicate<Entity>)from AbstractQuery
public EntityQuery removeIf(Predicate<Entity> predicate)Lazily filter by predicate (removes matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
skip(int)from AbstractQuery
public EntityQuery skip(int count)Skip a number of results.
Parameters
count- Count.
Returns
The query instance.
sort(Comparator<Entity>)from AbstractQuery
public EntityQuery sort(Comparator<Entity> comparator)Lazily add sorting.
Parameters
comparator- Comparator.
Returns
The query instance.
Also allowed
Every class has these, as in plain Java.
equals, toString