Class CitizensNavigator

java.lang.Object
net.citizensnpcs.npc.ai.CitizensNavigator
All Implemented Interfaces:
Runnable, Navigator

public class CitizensNavigator extends Object implements Navigator, Runnable
  • Constructor Details

    • CitizensNavigator

      public CitizensNavigator(NPC npc)
  • Method Details

    • cancelNavigation

      public void cancelNavigation()
      Description copied from interface: Navigator
      Cancels any running navigation towards a target.
      Specified by:
      cancelNavigation in interface Navigator
    • getDefaultParameters

      public NavigatorParameters getDefaultParameters()
      Description copied from interface: Navigator
      Returns the NavigatorParameters local to this navigator. These parameters are copied to local target parameters when a new target is started.
      Specified by:
      getDefaultParameters in interface Navigator
      Returns:
      The default parameters
      See Also:
    • getEntityTarget

      public EntityTarget getEntityTarget()
      Description copied from interface: Navigator
      Returns the current EntityTarget of the navigator, if any. May return null.
      Specified by:
      getEntityTarget in interface Navigator
      Returns:
      The current entity target
    • getLocalParameters

      public NavigatorParameters getLocalParameters()
      Description copied from interface: Navigator
      Returns the NavigatorParameters local to any current target execution. These are updated independently of the default parameters.
      Specified by:
      getLocalParameters in interface Navigator
      Returns:
      The local parameters
      See Also:
    • getNPC

      public NPC getNPC()
      Specified by:
      getNPC in interface Navigator
      Returns:
      The NPC attached to this navigator
    • getPathStrategy

      public PathStrategy getPathStrategy()
      Specified by:
      getPathStrategy in interface Navigator
      Returns:
      The current PathStrategy or null if the navigator is not pathfinding
    • getTargetAsLocation

      public Location getTargetAsLocation()
      Description copied from interface: Navigator
      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.
      Specified by:
      getTargetAsLocation in interface Navigator
      Returns:
      The target location
    • getTargetType

      public TargetType getTargetType()
      Specified by:
      getTargetType in interface Navigator
      Returns:
      The current TargetType of the navigator
    • isNavigating

      public boolean isNavigating()
      Specified by:
      isNavigating in interface Navigator
      Returns:
      Whether the navigator is currently pathing towards a target.
      See Also:
    • isPaused

      public boolean isPaused()
      Specified by:
      isPaused in interface Navigator
      Returns:
      Whether the navigator is currently paused
    • load

      public void load(DataKey root)
    • onDespawn

      public void onDespawn()
    • onSpawn

      public void onSpawn()
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • save

      public void save(DataKey root)
    • setPaused

      public void setPaused(boolean paused)
      Description copied from interface: Navigator
      Sets whether the navigator is paused and shouldn't process the path for now.
      Specified by:
      setPaused in interface Navigator
      Parameters:
      paused - Whether the navigator should be paused or not
    • setStraightLineTarget

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

      public void setStraightLineTarget(Location target)
      Description copied from interface: Navigator
      Sets the current navigation to a Location destination. The NPC will walk straight towards it without pathfinding.
      Specified by:
      setStraightLineTarget in interface Navigator
      Parameters:
      target - The destination
    • setTarget

      public void setTarget(Entity target, boolean aggressive)
      Description copied from interface: Navigator
      Sets the current navigation to an entity target.
      Specified by:
      setTarget in interface Navigator
      Parameters:
      target - The Entity to path towards
      aggressive - Whether to attack the target when close enough
    • setTarget

      public void setTarget(Function<NavigatorParameters,PathStrategy> strategy)
      Description copied from interface: Navigator
      Sets the current navigation to the specified strategy.
      Specified by:
      setTarget in interface Navigator
    • setTarget

      public void setTarget(Iterable<Vector> path)
      Description copied from interface: Navigator
      Sets the current navigation using a list of Vectors which will be moved between sequentially using the Citizens movement logic without pathfinding.
      Specified by:
      setTarget in interface Navigator
      Parameters:
      path - The path
    • setTarget

      public void setTarget(Location targetIn)
      Description copied from interface: Navigator
      Sets the current navigation to a Location destination.
      Specified by:
      setTarget in interface Navigator
      Parameters:
      targetIn - The destination