Interface Navigator

All Known Implementing Classes:
CitizensNavigator

public interface Navigator
Represents the pathfinding AI of an NPC. The navigator can path towards a single target at a time.
  • Method Details

    • cancelNavigation

      void cancelNavigation()
      Cancels any running navigation towards a target.
    • cancelNavigation

      void cancelNavigation(CancelReason reason)
      Cancels any running navigation towards a target with a specific CancelReason.
    • canNavigateTo

      boolean canNavigateTo(Location dest)
      See Also:
    • canNavigateTo

      boolean canNavigateTo(Location dest, NavigatorParameters params)
      Returns whether the NPC can navigate to the given destination with the navigator parameters.
    • getDefaultParameters

      NavigatorParameters getDefaultParameters()
      Returns the NavigatorParameters local to this navigator. These parameters are copied to local target parameters when a new target is started.
      Returns:
      The default parameters
      See Also:
    • getEntityTarget

      EntityTarget getEntityTarget()
      Returns the current EntityTarget of the navigator, if any. May return null.
      Returns:
      The current entity target
    • getLocalParameters

      NavigatorParameters getLocalParameters()
      Returns the NavigatorParameters local to any current target execution. These are updated independently of the default parameters.
      Returns:
      The local parameters
      See Also:
    • getNPC

      NPC getNPC()
      Returns:
      The NPC attached to this navigator
    • getPathStrategy

      PathStrategy getPathStrategy()
      Returns:
      The current PathStrategy or null if the navigator is not pathfinding
    • getTargetAsLocation

      Location getTargetAsLocation()
      Returns the current Location being navigated towards - this is not necessarily permanent and may change, for example when pathing towards a moving Entity. May return null.
      Returns:
      The target location
    • getTargetType

      TargetType getTargetType()
      Returns:
      The current TargetType of the navigator
    • isNavigating

      boolean isNavigating()
      Returns:
      Whether the navigator is currently pathing towards a target.
      See Also:
    • isPaused

      boolean isPaused()
      Returns:
      Whether the navigator is currently paused
    • setPaused

      void setPaused(boolean paused)
      Sets whether the navigator is paused and shouldn't process the path for now.
      Parameters:
      paused - Whether the navigator should be paused or not
    • setStraightLineTarget

      void setStraightLineTarget(Entity target, boolean aggressive)
      Sets the current navigation to an entity target. The NPC will walk towards them in a straight line without pathfinding.
      Parameters:
      target - The Entity to walk towards
      aggressive - Whether to attack the target when close enough
    • setStraightLineTarget

      void setStraightLineTarget(Location target)
      Sets the current navigation to a Location destination. The NPC will walk straight towards it without pathfinding.
      Parameters:
      target - The destination
    • setTarget

      void setTarget(Entity target, boolean aggressive)
      Sets the current navigation to an entity target.
      Parameters:
      target - The Entity to path towards
      aggressive - Whether to attack the target when close enough
    • setTarget

      void setTarget(Function<NavigatorParameters,PathStrategy> strategy)
      Sets the current navigation to the specified strategy.
      Parameters:
      strategy -
    • setTarget

      void setTarget(Iterable<Vector> path)
      Sets the current navigation using a list of Vectors which will be moved between sequentially using the Citizens movement logic without pathfinding.
      Parameters:
      path - The path
    • setTarget

      void setTarget(Location target)
      Sets the current navigation to a Location destination.
      Parameters:
      target - The destination