Class SceneEntityQueryResults<T extends SceneEntity>

java.lang.Object
net.storm.api.query.results.QueryResults<T,SceneEntityQueryResults<T>>
net.storm.api.query.results.SceneEntityQueryResults<T>
Type Parameters:
T - the type of scene entity contained in the results
All Implemented Interfaces:
Iterable<T>, Collection<T>

public class SceneEntityQueryResults<T extends SceneEntity> extends QueryResults<T,SceneEntityQueryResults<T>>
Result container for scene entity queries with distance-based operations.

This class extends QueryResults to provide scene entity-specific functionality, particularly methods for sorting entities by distance and finding the nearest or farthest entities from a reference point.

The class supports multiple distance calculation methods via the Distance enum:

Example usage:


 SceneEntityQueryResults<INPC> results = npcQuery.results();
 INPC nearestNpc = results.nearest(player);
 INPC farthestNpc = results.farthest(player);
 SceneEntityQueryResults<INPC> sorted = results.sortedByDistance(player);
 
  • Constructor Details

    • SceneEntityQueryResults

      public SceneEntityQueryResults(List<T> results)
      Constructs a new SceneEntityQueryResults wrapper around the specified list of entities.
      Parameters:
      results - the list of scene entities to wrap
  • Method Details

    • sortedByDistance

      public SceneEntityQueryResults<T> sortedByDistance(net.runelite.api.coords.WorldPoint to, Distance distance)
      Sorts the results by distance from a world point using the specified distance method.

      Entities are sorted in ascending order (nearest first).

      Parameters:
      to - the reference world point to calculate distances from
      distance - the distance calculation method to use
      Returns:
      this result instance for method chaining
    • sortedByDistance

      public SceneEntityQueryResults<T> sortedByDistance(net.runelite.api.coords.WorldPoint to)
      Sorts the results by distance from a world point using the default distance method.

      Entities are sorted in ascending order (nearest first).

      Parameters:
      to - the reference world point to calculate distances from
      Returns:
      this result instance for method chaining
    • sortedByDistance

      public SceneEntityQueryResults<T> sortedByDistance(Locatable to, Distance distance)
      Sorts the results by distance from a locatable entity using the specified distance method.

      Entities are sorted in ascending order (nearest first).

      Parameters:
      to - the reference locatable entity to calculate distances from
      distance - the distance calculation method to use
      Returns:
      this result instance for method chaining
    • sortedByDistance

      public SceneEntityQueryResults<T> sortedByDistance(Locatable to)
      Sorts the results by distance from a locatable entity using the default distance method.

      Entities are sorted in ascending order (nearest first).

      Parameters:
      to - the reference locatable entity to calculate distances from
      Returns:
      this result instance for method chaining
    • nearest

      public T nearest(Locatable to, Distance distance)
      Returns the entity nearest to the specified locatable using the specified distance method.
      Parameters:
      to - the reference locatable entity to calculate distances from
      distance - the distance calculation method to use
      Returns:
      the nearest entity, or null if the results are empty
    • nearest

      public T nearest(net.runelite.api.coords.WorldPoint to)
      Returns the entity nearest to the specified world point using the default distance method.
      Parameters:
      to - the reference world point to calculate distances from
      Returns:
      the nearest entity, or null if the results are empty
    • nearest

      public T nearest(net.runelite.api.coords.WorldPoint to, Distance distance)
      Returns the entity nearest to the specified world point using the specified distance method.
      Parameters:
      to - the reference world point to calculate distances from
      distance - the distance calculation method to use
      Returns:
      the nearest entity, or null if the results are empty
    • nearest

      public T nearest(Locatable locatable)
      Returns the entity nearest to the specified locatable using the default distance method.
      Parameters:
      locatable - the reference locatable entity to calculate distances from
      Returns:
      the nearest entity, or null if the results are empty
    • farthest

      public T farthest(Locatable locatable, Distance distance)
      Returns the entity farthest from the specified locatable using the specified distance method.
      Parameters:
      locatable - the reference locatable entity to calculate distances from
      distance - the distance calculation method to use
      Returns:
      the farthest entity, or null if the results are empty
    • farthest

      public T farthest(Locatable locatable)
      Returns the entity farthest from the specified locatable using the default distance method.
      Parameters:
      locatable - the reference locatable entity to calculate distances from
      Returns:
      the farthest entity, or null if the results are empty
    • farthest

      public T farthest(net.runelite.api.coords.WorldPoint to, Distance distance)
      Returns the entity farthest from the specified world point using the specified distance method.
      Parameters:
      to - the reference world point to calculate distances from
      distance - the distance calculation method to use
      Returns:
      the farthest entity, or null if the results are empty
    • farthest

      public T farthest(net.runelite.api.coords.WorldPoint to)
      Returns the entity farthest from the specified world point using the default distance method.
      Parameters:
      to - the reference world point to calculate distances from
      Returns:
      the farthest entity, or null if the results are empty