Class AsyncSpatialSearch

java.lang.Object
com.hypixel.hytale.builtin.portals.utils.posqueries.AsyncSpatialSearch

public final class AsyncSpatialSearch extends Object
Runs an AsyncPositionPredicate over candidate positions and returns the first accepted one.
  • Method Details

    • firstMatch

      @Nonnull public static CompletableFuture<org.joml.Vector3d> firstMatch(@Nonnull World world, @Nonnull Iterator<org.joml.Vector3d> candidates, @Nonnull AsyncPositionPredicate predicate)
      Tests candidates in order and returns the first the predicate accepts.

      Candidates the predicate answers without loading are consumed in the loop, so a search whose data is already in memory completes without leaving the calling thread. Chaining every candidate with thenCompose instead would nest one stack frame per candidate, because thenCompose runs its function inline on an already-completed future.

      Parameters:
      world - The world to test in. Also the executor that resumes a suspended search.
      candidates - The candidate positions, consumed lazily.
      predicate - The predicate to test each candidate with.
      Returns:
      a future completing with the first accepted candidate, or null if none.