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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final doublestatic final doubleFields inherited from class com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate
originalDestination, ourEntity, walkSpeedFactorFields 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
ConstructorsConstructorDescriptionMinecoloniesAdvancedPathNavigate(@NotNull net.minecraft.world.entity.Mob entity, net.minecraft.world.level.Level world) Instantiates the navigation of an ourEntity. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanMoveDirectly(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end) protected booleannet.minecraft.world.level.pathfinder.PathcreatePath(net.minecraft.core.BlockPos pos, int p_179680_2_) protected net.minecraft.world.level.pathfinder.PathFindercreatePathFinder(int p_179679_1_) protected voiddoStuckDetection(@NotNull net.minecraft.world.phys.Vec3 positionVec3) Don't let vanilla rapidly discard paths, set a timeout before its allowed to use stuck.protected voiddoubleGet the heuristic modifierprotected PathingOptionsResolve the effective pathing options for a newly created path job.Gets the current path resultnet.minecraft.core.BlockPosGets the safe destination the entity wants to travel tostatic doublegetSmartGroundY(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos.MutableBlockPos pos, double orgY) Similar to WalkNodeProcessor.getGroundY but not broken.doubleReturns the stuck handler used by the navigatorprotected @NotNull net.minecraft.world.phys.Vec3booleanisDone()booleanisStuck()@Nullable PathResult<PathJobMoveAwayFromLocation>moveAwayFromLivingEntity(@NotNull net.minecraft.world.entity.Entity e, double distance, double speed) Used to path away from a ourEntity.booleanmoveTo(double x, double y, double z, double speedFactor) Deprecated.booleanmoveTo(@Nullable net.minecraft.world.level.pathfinder.Path path, double speedFactor) Deprecated.booleanmoveTo(net.minecraft.world.entity.Entity entityIn, double speedFactor) voidrecalc()Triggers an indirect recalc, isDone() returns true nowvoidvoidsetCanFloat(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 executevoidsetPauseTicks(int pauseTicks) Sets the navigation to not accept new jobs for a timevoidsetSafeDestinationPos(net.minecraft.core.BlockPos pos) Sets the desired position to reach, used also for stuckhandlingvoidsetSpeedModifier(double speedFactor) voidsetStuckHandler(IStuckHandler stuckHandler) Sets the stuck handlervoidsetSwimSpeedFactor(double factor) voidstop()Stop indicates that the entity no longer desires to move.voidtick()protected voidtrimPath()voidUpdates the saved node referencesprotected @Nullable PathResult<PathJobMoveAwayFromLocation>walkAwayFrom(net.minecraft.core.BlockPos avoid, double range, double speedFactor, boolean safeDestination) Used to path away from a position.protected PathResult<PathJobMoveCloseToXNearY>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 positionbooleanwalkTo(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.@Nullable PathResult<PathJobMoveToLocation>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.protected PathResult<PathJobRandomPos>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 restrictionsprotected PathResult<PathJobRandomPos>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 restrictionsprotected @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 blocksMethods inherited from class com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate
getOurEntity, getPathingOptionsMethods inherited from class net.minecraft.world.entity.ai.navigation.GroundPathNavigation
canOpenDoors, canPassDoors, createPath, hasValidPathType, setAvoidSun, setCanOpenDoors, setCanPassDoors, setCanWalkOverFencesMethods 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, shouldRecomputePathMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.entity.pathfinding.IMinecoloniesNavigator
getOurEntity
-
Field Details
-
MIN_Y_DISTANCE
public static final double MIN_Y_DISTANCE- See Also:
-
MAX_SPEED_ALLOWED
public static final int MAX_SPEED_ALLOWED- See Also:
-
MIN_SPEED_ALLOWED
public static final double MIN_SPEED_ALLOWED- See Also:
-
-
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:AbstractAdvancedPathNavigateUsed to path away from a position.- Specified by:
walkAwayFromin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateAttemps to move in the given direction, walking at least range blocks- Specified by:
walkTowardsin classAbstractAdvancedPathNavigate- Returns:
-
walkToRandomPos
@Nullable protected @Nullable PathResult<PathJobRandomPos> walkToRandomPos(int range, double speedFactor) Description copied from class:AbstractAdvancedPathNavigateUsed to path towards a random pos.- Specified by:
walkToRandomPosin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to path towards a random pos.- Specified by:
walkToRandomPosAroundin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to path towards a random pos within some restrictions- Specified by:
walkToRandomPosin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to path towards a random pos within some restrictions- Specified by:
walkToRandomPosin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateWalks towards the desired position, while trying to not steer too far from the nearby position- Specified by:
walkCloseToXNearYin classAbstractAdvancedPathNavigate- 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:IMinecoloniesNavigatorSets a new pathjob to execute- Specified by:
setPathJobin interfaceIMinecoloniesNavigator- Parameters:
job- to run- Returns:
- null or new pathresult
-
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:
isDonein classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
tick
public void tick()- Overrides:
tickin classnet.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:AbstractAdvancedPathNavigateTry to move to a certain position.- Specified by:
walkToin classAbstractAdvancedPathNavigatespeedFactor- 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:AbstractAdvancedPathNavigateAttempt to move to a specific pos.- Specified by:
walkToin classAbstractAdvancedPathNavigate- 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:
createPathFinderin classnet.minecraft.world.entity.ai.navigation.GroundPathNavigation
-
canUpdatePath
protected boolean canUpdatePath()- Overrides:
canUpdatePathin classnet.minecraft.world.entity.ai.navigation.GroundPathNavigation
-
getTempMobPos
@NotNull protected @NotNull net.minecraft.world.phys.Vec3 getTempMobPos()- Overrides:
getTempMobPosin classnet.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:
createPathin classnet.minecraft.world.entity.ai.navigation.GroundPathNavigation
-
canMoveDirectly
protected boolean canMoveDirectly(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end) - Overrides:
canMoveDirectlyin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
getSpeedFactor
public double getSpeedFactor() -
setSpeedModifier
public void setSpeedModifier(double speedFactor) - Overrides:
setSpeedModifierin classnet.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:
moveToin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
moveTo
public boolean moveTo(net.minecraft.world.entity.Entity entityIn, double speedFactor) - Overrides:
moveToin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
trimPath
protected void trimPath()- Overrides:
trimPathin classnet.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:
moveToin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
followThePath
protected void followThePath()- Overrides:
followThePathin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
recomputePath
public void recomputePath()- Overrides:
recomputePathin classnet.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:
doStuckDetectionin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
stop
public void stop()Stop indicates that the entity no longer desires to move.- Overrides:
stopin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
recalc
public void recalc()Triggers an indirect recalc, isDone() returns true now- Specified by:
recalcin interfaceIMinecoloniesNavigator
-
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:AbstractAdvancedPathNavigateUsed to find a tree.- Specified by:
walkToTreein classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to find a tree.- Specified by:
walkToTreein classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to walk a living ourEntity with a speed.- Specified by:
walkToEntityin classAbstractAdvancedPathNavigate- 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:AbstractAdvancedPathNavigateUsed to path away from a ourEntity.- Specified by:
moveAwayFromLivingEntityin classAbstractAdvancedPathNavigate- 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:
setCanFloatin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
getSafeDestination
public net.minecraft.core.BlockPos getSafeDestination()Description copied from interface:IMinecoloniesNavigatorGets the safe destination the entity wants to travel to- Specified by:
getSafeDestinationin interfaceIMinecoloniesNavigator- Returns:
-
setSafeDestinationPos
public void setSafeDestinationPos(net.minecraft.core.BlockPos pos) Description copied from class:AbstractAdvancedPathNavigateSets the desired position to reach, used also for stuckhandling- Specified by:
setSafeDestinationPosin classAbstractAdvancedPathNavigate
-
setStuckHandler
Sets the stuck handler- Specified by:
setStuckHandlerin classAbstractAdvancedPathNavigate- Parameters:
stuckHandler- handler to set
-
setSwimSpeedFactor
public void setSwimSpeedFactor(double factor) - Specified by:
setSwimSpeedFactorin classAbstractAdvancedPathNavigate
-
getAvgHeuristicModifier
public double getAvgHeuristicModifier()Description copied from interface:IDynamicHeuristicNavigatorGet the heuristic modifier- Specified by:
getAvgHeuristicModifierin interfaceIDynamicHeuristicNavigator
-
setPauseTicks
public void setPauseTicks(int pauseTicks) Description copied from class:AbstractAdvancedPathNavigateSets the navigation to not accept new jobs for a time- Specified by:
setPauseTicksin interfaceIMinecoloniesNavigator- Specified by:
setPauseTicksin classAbstractAdvancedPathNavigate
-
getPathResult
Description copied from class:AbstractAdvancedPathNavigateGets the current path result- Specified by:
getPathResultin interfaceIMinecoloniesNavigator- Specified by:
getPathResultin classAbstractAdvancedPathNavigate- Returns:
-
getStuckHandler
Description copied from interface:IMinecoloniesNavigatorReturns the stuck handler used by the navigator- Specified by:
getStuckHandlerin interfaceIMinecoloniesNavigator- Returns:
-
isStuck
public boolean isStuck()- Overrides:
isStuckin classnet.minecraft.world.entity.ai.navigation.PathNavigation
-
updateNodeReferences
public void updateNodeReferences()Description copied from interface:IMinecoloniesNavigatorUpdates the saved node references- Specified by:
updateNodeReferencesin interfaceIMinecoloniesNavigator
-