Class MinecoloniesAdvancedPathNavigate

java.lang.Object
net.minecraft.world.entity.ai.navigation.PathNavigation
net.minecraft.world.entity.ai.navigation.GroundPathNavigation
com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate
com.minecolonies.core.entity.pathfinding.navigation.MinecoloniesAdvancedPathNavigate
All Implemented Interfaces:
IDynamicHeuristicNavigator, IMinecoloniesNavigator

public class MinecoloniesAdvancedPathNavigate extends AbstractAdvancedPathNavigate implements IDynamicHeuristicNavigator, IMinecoloniesNavigator
Minecolonies async PathNavigate.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final double
     
    static final double
     

    Fields inherited from class com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate

    originalDestination, ourEntity, walkSpeedFactor

    Fields inherited from class net.minecraft.world.entity.ai.navigation.PathNavigation

    hasDelayedRecomputation, lastStuckCheck, lastStuckCheckPos, lastTimeoutCheck, level, maxDistanceToWaypoint, mob, nodeEvaluator, path, speedModifier, tick, timeLastRecompute, timeoutCachedNode, timeoutLimit, timeoutTimer
  • Constructor Summary

    Constructors
    Constructor
    Description
    MinecoloniesAdvancedPathNavigate(@NotNull net.minecraft.world.entity.Mob entity, net.minecraft.world.level.Level world)
    Instantiates the navigation of an ourEntity.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    canMoveDirectly(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end)
     
    protected boolean
     
    net.minecraft.world.level.pathfinder.Path
    createPath(net.minecraft.core.BlockPos pos, int p_179680_2_)
     
    protected net.minecraft.world.level.pathfinder.PathFinder
    createPathFinder(int p_179679_1_)
     
    protected void
    doStuckDetection(@NotNull net.minecraft.world.phys.Vec3 positionVec3)
    Don't let vanilla rapidly discard paths, set a timeout before its allowed to use stuck.
    protected void
     
    double
    Get the heuristic modifier
    protected PathingOptions
    Resolve the effective pathing options for a newly created path job.
    Gets the current path result
    net.minecraft.core.BlockPos
    Gets the safe destination the entity wants to travel to
    static double
    getSmartGroundY(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos.MutableBlockPos pos, double orgY)
    Similar to WalkNodeProcessor.getGroundY but not broken.
    double
     
    Returns the stuck handler used by the navigator
    protected @NotNull net.minecraft.world.phys.Vec3
     
    boolean
     
    boolean
     
    moveAwayFromLivingEntity(@NotNull net.minecraft.world.entity.Entity e, double distance, double speed)
    Used to path away from a ourEntity.
    boolean
    moveTo(double x, double y, double z, double speedFactor)
    Deprecated.
    boolean
    moveTo(@Nullable net.minecraft.world.level.pathfinder.Path path, double speedFactor)
    Deprecated.
    boolean
    moveTo(net.minecraft.world.entity.Entity entityIn, double speedFactor)
     
    void
    Triggers an indirect recalc, isDone() returns true now
    void
     
    void
    setCanFloat(boolean canSwim)
     
    <T extends AbstractPathJob>
    @Nullable PathResult<T>
    setPathJob(@NotNull AbstractPathJob job, net.minecraft.core.BlockPos dest, double speedFactor, boolean safeDestination)
    Sets a new pathjob to execute
    void
    setPauseTicks(int pauseTicks)
    Sets the navigation to not accept new jobs for a time
    void
    setSafeDestinationPos(net.minecraft.core.BlockPos pos)
    Sets the desired position to reach, used also for stuckhandling
    void
    setSpeedModifier(double speedFactor)
     
    void
    Sets the stuck handler
    void
    setSwimSpeedFactor(double factor)
     
    void
    Stop indicates that the entity no longer desires to move.
    void
     
    protected void
     
    walkAwayFrom(net.minecraft.core.BlockPos avoid, double range, double speedFactor, boolean safeDestination)
    Used to path away from a position.
    walkCloseToXNearY(net.minecraft.core.BlockPos desiredPosition, net.minecraft.core.BlockPos nearbyPosition, int distToDesired, double speedFactor, boolean safeDestination)
    Walks towards the desired position, while trying to not steer too far from the nearby position
    boolean
    walkTo(net.minecraft.core.BlockPos pos, double speedFactor)
    Deprecated.
    protected @Nullable PathResult<PathJobMoveToLocation>
    walkTo(net.minecraft.core.BlockPos desiredPos, double speedFactor, boolean safeDestination)
    Try to move to a certain position.
    walkToEntity(@NotNull net.minecraft.world.entity.Entity e, double speed)
    Used to walk a living ourEntity with a speed.
    protected @Nullable PathResult<PathJobRandomPos>
    walkToRandomPos(int range, double speedFactor)
    Used to path towards a random pos.
    walkToRandomPos(int range, double speedFactor, net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners)
    Used to path towards a random pos within some restrictions
    walkToRandomPos(int range, double speedFactor, net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners, boolean preferInside)
    Used to path towards a random pos within some restrictions
    protected @Nullable PathResult<PathJobRandomPos>
    walkToRandomPosAround(int range, double speedFactor, net.minecraft.core.BlockPos pos)
    Used to path towards a random pos.
    walkToTree(int range, double speed, List<ItemStorage> excludedTrees, int dyntreesize, IColony colony)
    Used to find a tree.
    walkToTree(net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction, double speed, List<ItemStorage> excludedTrees, int dyntreesize, IColony colony)
    Used to find a tree.
    protected @Nullable PathResult<AbstractPathJob>
    walkTowards(net.minecraft.core.BlockPos towards, double range, double speedFactor)
    Attemps to move in the given direction, walking at least range blocks

    Methods inherited from class com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate

    getOurEntity, getPathingOptions

    Methods inherited from class net.minecraft.world.entity.ai.navigation.GroundPathNavigation

    canOpenDoors, canPassDoors, createPath, hasValidPathType, setAvoidSun, setCanOpenDoors, setCanPassDoors, setCanWalkOverFences

    Methods inherited from class net.minecraft.world.entity.ai.navigation.PathNavigation

    canCutCorner, canFloat, createPath, createPath, createPath, createPath, createPath, createPath, getGroundY, getMaxDistanceToWaypoint, getNodeEvaluator, getPath, getTargetPos, isClearForMovementBetween, isInLiquid, isInProgress, isStableDestination, resetMaxVisitedNodesMultiplier, setMaxVisitedNodesMultiplier, shouldRecomputePath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.minecolonies.api.entity.pathfinding.IMinecoloniesNavigator

    getOurEntity
  • Field Details

  • Constructor Details

    • MinecoloniesAdvancedPathNavigate

      public MinecoloniesAdvancedPathNavigate(@NotNull @NotNull net.minecraft.world.entity.Mob entity, net.minecraft.world.level.Level world)
      Instantiates the navigation of an ourEntity.
      Parameters:
      entity - the ourEntity.
      world - the world it is in.
  • Method Details

    • walkAwayFrom

      @Nullable protected @Nullable PathResult<PathJobMoveAwayFromLocation> walkAwayFrom(net.minecraft.core.BlockPos avoid, double range, double speedFactor, boolean safeDestination)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path away from a position.
      Specified by:
      walkAwayFrom in class AbstractAdvancedPathNavigate
      Parameters:
      avoid - the position to avoid.
      range - the range he should move out of.
      speedFactor - the speed to run at.
      safeDestination - if the destination is save and should be set.
      Returns:
      the result of the pathing.
    • walkTowards

      @Nullable protected @Nullable PathResult<AbstractPathJob> walkTowards(net.minecraft.core.BlockPos towards, double range, double speedFactor)
      Description copied from class: AbstractAdvancedPathNavigate
      Attemps to move in the given direction, walking at least range blocks
      Specified by:
      walkTowards in class AbstractAdvancedPathNavigate
      Returns:
    • walkToRandomPos

      @Nullable protected @Nullable PathResult<PathJobRandomPos> walkToRandomPos(int range, double speedFactor)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path towards a random pos.
      Specified by:
      walkToRandomPos in class AbstractAdvancedPathNavigate
      Parameters:
      range - the range he should move out of.
      speedFactor - the speed to run at.
      Returns:
      the result of the pathing.
    • walkToRandomPosAround

      @Nullable protected @Nullable PathResult<PathJobRandomPos> walkToRandomPosAround(int range, double speedFactor, net.minecraft.core.BlockPos pos)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path towards a random pos.
      Specified by:
      walkToRandomPosAround in class AbstractAdvancedPathNavigate
      Parameters:
      range - the range he should move out of.
      speedFactor - the speed to run at.
      pos - the pos to circle around.
      Returns:
      the result of the pathing.
    • walkToRandomPos

      protected PathResult<PathJobRandomPos> walkToRandomPos(int range, double speedFactor, net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path towards a random pos within some restrictions
      Specified by:
      walkToRandomPos in class AbstractAdvancedPathNavigate
      Parameters:
      range - the range he should move out of.
      speedFactor - the speed to run at.
      corners - the corners they can't leave.
      Returns:
      the result of the pathing.
    • walkToRandomPos

      protected PathResult<PathJobRandomPos> walkToRandomPos(int range, double speedFactor, net.minecraft.util.Tuple<net.minecraft.core.BlockPos,net.minecraft.core.BlockPos> corners, boolean preferInside)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path towards a random pos within some restrictions
      Specified by:
      walkToRandomPos in class AbstractAdvancedPathNavigate
      Parameters:
      range - the range he should move out of.
      speedFactor - the speed to run at.
      corners - the corners they can't leave.
      Returns:
      the result of the pathing.
    • walkCloseToXNearY

      protected PathResult<PathJobMoveCloseToXNearY> walkCloseToXNearY(net.minecraft.core.BlockPos desiredPosition, net.minecraft.core.BlockPos nearbyPosition, int distToDesired, double speedFactor, boolean safeDestination)
      Description copied from class: AbstractAdvancedPathNavigate
      Walks towards the desired position, while trying to not steer too far from the nearby position
      Specified by:
      walkCloseToXNearY in class AbstractAdvancedPathNavigate
      Returns:
    • setPathJob

      @Nullable public <T extends AbstractPathJob> @Nullable PathResult<T> setPathJob(@NotNull @NotNull AbstractPathJob job, net.minecraft.core.BlockPos dest, double speedFactor, boolean safeDestination)
      Description copied from interface: IMinecoloniesNavigator
      Sets a new pathjob to execute
      Specified by:
      setPathJob in interface IMinecoloniesNavigator
      Parameters:
      job - to run
      Returns:
      null or new pathresult
    • getOptionsForPathJob

      protected PathingOptions getOptionsForPathJob()
      Resolve the effective pathing options for a newly created path job.

      Mounted units should path according to their vehicle's constraints without mutating either navigator's long-lived settings. The returned options are copied into the job.

      Returns:
      the pathing options for the next job
    • isDone

      public boolean isDone()
      Overrides:
      isDone in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • tick

      public void tick()
      Overrides:
      tick in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • getSmartGroundY

      public static double getSmartGroundY(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos.MutableBlockPos pos, double orgY)
      Similar to WalkNodeProcessor.getGroundY but not broken. This checks if the block below the position we're trying to move to reaches into the block above, if so, it has to aim a little bit higher.
      Parameters:
      world - the world.
      pos - the position to check.
      orgY - original y level
      Returns:
      the next y level to go to.
    • walkTo

      @Nullable protected @Nullable PathResult<PathJobMoveToLocation> walkTo(net.minecraft.core.BlockPos desiredPos, double speedFactor, boolean safeDestination)
      Description copied from class: AbstractAdvancedPathNavigate
      Try to move to a certain position.
      Specified by:
      walkTo in class AbstractAdvancedPathNavigate
      speedFactor - the speed to walk.
      Returns:
      the PathResult.
    • walkTo

      @Deprecated(since="Do not use, always returns true, vanilla override") public boolean walkTo(net.minecraft.core.BlockPos pos, double speedFactor)
      Deprecated.
      Description copied from class: AbstractAdvancedPathNavigate
      Attempt to move to a specific pos.
      Specified by:
      walkTo in class AbstractAdvancedPathNavigate
      Parameters:
      pos - the position to move to.
      speedFactor - the speed.
      Returns:
      true if successful.
    • createPathFinder

      protected net.minecraft.world.level.pathfinder.PathFinder createPathFinder(int p_179679_1_)
      Overrides:
      createPathFinder in class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
    • canUpdatePath

      protected boolean canUpdatePath()
      Overrides:
      canUpdatePath in class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
    • getTempMobPos

      @NotNull protected @NotNull net.minecraft.world.phys.Vec3 getTempMobPos()
      Overrides:
      getTempMobPos in class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
    • createPath

      public net.minecraft.world.level.pathfinder.Path createPath(net.minecraft.core.BlockPos pos, int p_179680_2_)
      Overrides:
      createPath in class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
    • canMoveDirectly

      protected boolean canMoveDirectly(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end)
      Overrides:
      canMoveDirectly in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • getSpeedFactor

      public double getSpeedFactor()
    • setSpeedModifier

      public void setSpeedModifier(double speedFactor)
      Overrides:
      setSpeedModifier in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • moveTo

      @Deprecated(since="Do not use, always returns true, vanilla override") public boolean moveTo(double x, double y, double z, double speedFactor)
      Deprecated.
      Overrides:
      moveTo in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • moveTo

      public boolean moveTo(net.minecraft.world.entity.Entity entityIn, double speedFactor)
      Overrides:
      moveTo in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • trimPath

      protected void trimPath()
      Overrides:
      trimPath in class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
    • moveTo

      @Deprecated(since="Do not use, always returns true, vanilla override") public boolean moveTo(@Nullable @Nullable net.minecraft.world.level.pathfinder.Path path, double speedFactor)
      Deprecated.
      Overrides:
      moveTo in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • followThePath

      protected void followThePath()
      Overrides:
      followThePath in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • recomputePath

      public void recomputePath()
      Overrides:
      recomputePath in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • doStuckDetection

      protected void doStuckDetection(@NotNull @NotNull net.minecraft.world.phys.Vec3 positionVec3)
      Don't let vanilla rapidly discard paths, set a timeout before its allowed to use stuck.
      Overrides:
      doStuckDetection in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • stop

      public void stop()
      Stop indicates that the entity no longer desires to move.
      Overrides:
      stop in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • recalc

      public void recalc()
      Triggers an indirect recalc, isDone() returns true now
      Specified by:
      recalc in interface IMinecoloniesNavigator
    • walkToTree

      public TreePathResult walkToTree(net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction, double speed, List<ItemStorage> excludedTrees, int dyntreesize, IColony colony)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to find a tree.
      Specified by:
      walkToTree in class AbstractAdvancedPathNavigate
      Parameters:
      startRestriction - the start of the restricted area.
      endRestriction - the end of the restricted area.
      speed - walking speed.
      excludedTrees - the trees which should be cut.
      Returns:
      the result of the search.
    • walkToTree

      public TreePathResult walkToTree(int range, double speed, List<ItemStorage> excludedTrees, int dyntreesize, IColony colony)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to find a tree.
      Specified by:
      walkToTree in class AbstractAdvancedPathNavigate
      Parameters:
      range - in the range.
      speed - walking speed.
      excludedTrees - the trees which should be cut.
      Returns:
      the result of the search.
    • walkToEntity

      @Nullable public @Nullable PathResult<PathJobMoveToLocation> walkToEntity(@NotNull @NotNull net.minecraft.world.entity.Entity e, double speed)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to walk a living ourEntity with a speed.
      Specified by:
      walkToEntity in class AbstractAdvancedPathNavigate
      Parameters:
      e - the ourEntity.
      speed - the speed.
      Returns:
      the result.
    • moveAwayFromLivingEntity

      @Nullable public @Nullable PathResult<PathJobMoveAwayFromLocation> moveAwayFromLivingEntity(@NotNull @NotNull net.minecraft.world.entity.Entity e, double distance, double speed)
      Description copied from class: AbstractAdvancedPathNavigate
      Used to path away from a ourEntity.
      Specified by:
      moveAwayFromLivingEntity in class AbstractAdvancedPathNavigate
      Parameters:
      e - the ourEntity.
      distance - the distance to move to.
      speed - the speed to run at.
      Returns:
      the result of the pathing.
    • setCanFloat

      public void setCanFloat(boolean canSwim)
      Overrides:
      setCanFloat in class net.minecraft.world.entity.ai.navigation.PathNavigation
    • getSafeDestination

      public net.minecraft.core.BlockPos getSafeDestination()
      Description copied from interface: IMinecoloniesNavigator
      Gets the safe destination the entity wants to travel to
      Specified by:
      getSafeDestination in interface IMinecoloniesNavigator
      Returns:
    • setSafeDestinationPos

      public void setSafeDestinationPos(net.minecraft.core.BlockPos pos)
      Description copied from class: AbstractAdvancedPathNavigate
      Sets the desired position to reach, used also for stuckhandling
      Specified by:
      setSafeDestinationPos in class AbstractAdvancedPathNavigate
    • setStuckHandler

      public void setStuckHandler(IStuckHandler stuckHandler)
      Sets the stuck handler
      Specified by:
      setStuckHandler in class AbstractAdvancedPathNavigate
      Parameters:
      stuckHandler - handler to set
    • setSwimSpeedFactor

      public void setSwimSpeedFactor(double factor)
      Specified by:
      setSwimSpeedFactor in class AbstractAdvancedPathNavigate
    • getAvgHeuristicModifier

      public double getAvgHeuristicModifier()
      Description copied from interface: IDynamicHeuristicNavigator
      Get the heuristic modifier
      Specified by:
      getAvgHeuristicModifier in interface IDynamicHeuristicNavigator
    • setPauseTicks

      public void setPauseTicks(int pauseTicks)
      Description copied from class: AbstractAdvancedPathNavigate
      Sets the navigation to not accept new jobs for a time
      Specified by:
      setPauseTicks in interface IMinecoloniesNavigator
      Specified by:
      setPauseTicks in class AbstractAdvancedPathNavigate
    • getPathResult

      public PathResult getPathResult()
      Description copied from class: AbstractAdvancedPathNavigate
      Gets the current path result
      Specified by:
      getPathResult in interface IMinecoloniesNavigator
      Specified by:
      getPathResult in class AbstractAdvancedPathNavigate
      Returns:
    • getStuckHandler

      Description copied from interface: IMinecoloniesNavigator
      Returns the stuck handler used by the navigator
      Specified by:
      getStuckHandler in interface IMinecoloniesNavigator
      Returns:
    • isStuck

      public boolean isStuck()
      Overrides:
      isStuck in class net.minecraft.world.entity.ai.navigation.PathNavigation