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

      @Nullable protected 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

      @Nullable private 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
  • Constructor Details

    • PathNavigation

      public PathNavigation(Mob pMob, Level pLevel)
  • Method Details

    • resetMaxVisitedNodesMultiplier

      public void resetMaxVisitedNodesMultiplier()
    • setMaxVisitedNodesMultiplier

      public void setMaxVisitedNodesMultiplier(float pMultiplier)
    • getTargetPos

      @Nullable public BlockPos getTargetPos()
    • createPathFinder

      protected abstract PathFinder createPathFinder(int pMaxVisitedNodes)
    • setSpeedModifier

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

      public void recomputePath()
    • createPath

      @Nullable public final Path createPath(double pX, double pY, double pZ, int pAccuracy)
      Returns path to given BlockPos
    • createPath

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

      @Nullable public Path createPath(Set<BlockPos> pPositions, int pDistance)
    • createPath

      @Nullable public Path createPath(BlockPos pPos, int pAccuracy)
      Returns path to given BlockPos
    • createPath

      @Nullable public Path createPath(BlockPos pPos, int pRegionOffset, int pAccuracy)
    • createPath

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

      @Nullable protected Path createPath(Set<BlockPos> pTargets, int pRegionOffset, boolean pOffsetUpward, int pAccuracy)
      Returns a path to one of the given targets or null
    • createPath

      @Nullable protected Path createPath(Set<BlockPos> pTargets, int pRegionOffset, boolean pOffsetUpward, int pAccuracy, float pFollowRange)
    • moveTo

      public boolean moveTo(double pX, double pY, double pZ, double pSpeed)
      Try to find and set a path to XYZ. Returns true if successful.
    • moveTo

      public boolean moveTo(double pX, double pY, double pZ, int pAccuracy, double pSpeed)
    • moveTo

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

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

      @Nullable public Path getPath()
    • tick

      public void tick()
    • getGroundY

      protected double getGroundY(Vec3 pVec)
    • followThePath

      protected void followThePath()
    • shouldTargetNextNodeInDirection

      private boolean shouldTargetNextNodeInDirection(Vec3 pVec)
    • doStuckDetection

      protected void doStuckDetection(Vec3 pPositionVec3)
      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 pPosVec31, Vec3 pPosVec32)
      Checks if the specified entity can safely walk to the specified location.
    • canCutCorner

      public boolean canCutCorner(PathType pPathType)
    • isClearForMovementBetween

      protected static boolean isClearForMovementBetween(Mob pMob, Vec3 pPos1, Vec3 pPos2, boolean pAllowSwimming)
    • isStableDestination

      public boolean isStableDestination(BlockPos pPos)
    • getNodeEvaluator

      public NodeEvaluator getNodeEvaluator()
    • setCanFloat

      public void setCanFloat(boolean pCanSwim)
    • canFloat

      public boolean canFloat()
    • shouldRecomputePath

      public boolean shouldRecomputePath(BlockPos pPos)
    • getMaxDistanceToWaypoint

      public float getMaxDistanceToWaypoint()
    • isStuck

      public boolean isStuck()