Class PathNavigation

java.lang.Object
net.minecraft.world.entity.ai.navigation.PathNavigation
Direct Known Subclasses:
AmphibiousPathNavigation, FlyingPathNavigation, GroundPathNavigation, WaterBoundPathNavigation

public abstract class PathNavigation extends Object
  • Field Details

    • MAX_TIME_RECOMPUTE

      private static final int MAX_TIME_RECOMPUTE
      See Also:
    • STUCK_CHECK_INTERVAL

      private static final int STUCK_CHECK_INTERVAL
      See Also:
    • STUCK_THRESHOLD_DISTANCE_FACTOR

      private static final float STUCK_THRESHOLD_DISTANCE_FACTOR
      See Also:
    • mob

      protected final Mob mob
    • level

      protected final Level level
    • path

      protected @Nullable Path path
    • speedModifier

      protected double speedModifier
    • tick

      protected int tick
    • lastStuckCheck

      protected int lastStuckCheck
    • lastStuckCheckPos

      protected Vec3 lastStuckCheckPos
    • timeoutCachedNode

      protected Vec3i timeoutCachedNode
    • timeoutTimer

      protected long timeoutTimer
    • lastTimeoutCheck

      protected long lastTimeoutCheck
    • timeoutLimit

      protected double timeoutLimit
    • maxDistanceToWaypoint

      protected float maxDistanceToWaypoint
    • hasDelayedRecomputation

      protected boolean hasDelayedRecomputation
      Whether the path can be changed by
      invalid reference
      onUpdateNavigation()
    • timeLastRecompute

      protected long timeLastRecompute
    • nodeEvaluator

      protected NodeEvaluator nodeEvaluator
    • targetPos

      private @Nullable BlockPos targetPos
    • reachRange

      private int reachRange
      Distance in which a path point counts as target-reaching
    • maxVisitedNodesMultiplier

      private float maxVisitedNodesMultiplier
    • pathFinder

      private final PathFinder pathFinder
    • isStuck

      private boolean isStuck
    • requiredPathLength

      private float requiredPathLength
  • Constructor Details

    • PathNavigation

      public PathNavigation(Mob mob, Level level)
  • Method Details

    • updatePathfinderMaxVisitedNodes

      public void updatePathfinderMaxVisitedNodes()
    • setRequiredPathLength

      public void setRequiredPathLength(float length)
    • getMaxPathLength

      private float getMaxPathLength()
    • resetMaxVisitedNodesMultiplier

      public void resetMaxVisitedNodesMultiplier()
    • setMaxVisitedNodesMultiplier

      public void setMaxVisitedNodesMultiplier(float maxVisitedNodesMultiplier)
    • getTargetPos

      public @Nullable BlockPos getTargetPos()
    • createPathFinder

      protected abstract PathFinder createPathFinder(int maxVisitedNodes)
    • setSpeedModifier

      public void setSpeedModifier(double speedModifier)
      Sets the speed
    • recomputePath

      public void recomputePath()
    • createPath

      public final @Nullable Path createPath(double x, double y, double z, int reachRange)
      Returns path to given BlockPos
    • createPath

      public @Nullable Path createPath(Stream<BlockPos> positions, int reachRange)
      Returns a path to one of the elements of the stream or null
    • createPath

      public @Nullable Path createPath(Set<BlockPos> positions, int reachRange)
    • createPath

      public @Nullable Path createPath(BlockPos pos, int reachRange)
      Returns path to given BlockPos
    • createPath

      public @Nullable Path createPath(BlockPos pos, int reachRange, int maxPathLength)
    • createPath

      public @Nullable Path createPath(Entity target, int reachRange)
      Returns a path to the given entity or null
    • createPath

      protected @Nullable Path createPath(Set<BlockPos> targets, int radiusOffset, boolean above, int reachRange)
      Returns a path to one of the given targets or null
    • createPath

      protected @Nullable Path createPath(Set<BlockPos> targets, int radiusOffset, boolean above, int reachRange, float maxPathLength)
    • moveTo

      public boolean moveTo(double x, double y, double z, double speedModifier)
      Try to find and set a path to XYZ. Returns true if successful.
    • moveTo

      public boolean moveTo(double x, double y, double z, int reachRange, double speedModifier)
    • moveTo

      public boolean moveTo(Entity target, double speedModifier)
      Try to find and set a path to EntityLiving. Returns true if successful.
    • moveTo

      public boolean moveTo(@Nullable Path newPath, double speedModifier)
      Sets a new path. If it's different from the old path. Checks to adjust path for sun avoiding, and stores start coords.
    • getPath

      public @Nullable Path getPath()
    • tick

      public void tick()
    • getGroundY

      protected double getGroundY(Vec3 target)
    • followThePath

      protected void followThePath()
    • shouldTargetNextNodeInDirection

      private boolean shouldTargetNextNodeInDirection(Vec3 mobPosition)
    • doStuckDetection

      protected void doStuckDetection(Vec3 mobPos)
      Checks if entity haven't been moved when last checked and if so, stops the current navigation.
    • timeoutPath

      private void timeoutPath()
    • resetStuckTimeout

      private void resetStuckTimeout()
    • isDone

      public boolean isDone()
    • isInProgress

      public boolean isInProgress()
    • stop

      public void stop()
    • getTempMobPos

      protected abstract Vec3 getTempMobPos()
    • canUpdatePath

      protected abstract boolean canUpdatePath()
    • trimPath

      protected void trimPath()
    • canMoveDirectly

      protected boolean canMoveDirectly(Vec3 startPos, Vec3 stopPos)
      Checks if the specified entity can safely walk to the specified location.
    • canCutCorner

      public boolean canCutCorner(PathType pathType)
    • isClearForMovementBetween

      protected static boolean isClearForMovementBetween(Mob mob, Vec3 startPos, Vec3 stopPos, boolean blockedByFluids)
    • isStableDestination

      public boolean isStableDestination(BlockPos pos)
    • getNodeEvaluator

      public NodeEvaluator getNodeEvaluator()
    • setCanFloat

      public void setCanFloat(boolean canFloat)
    • canFloat

      public boolean canFloat()
    • shouldRecomputePath

      public boolean shouldRecomputePath(BlockPos pos)
    • getMaxDistanceToWaypoint

      public float getMaxDistanceToWaypoint()
    • isStuck

      public boolean isStuck()
    • canNavigateGround

      public abstract boolean canNavigateGround()
    • setCanOpenDoors

      public void setCanOpenDoors(boolean canOpenDoors)