Class PathNavigation
java.lang.Object
net.minecraft.world.entity.ai.navigation.PathNavigation
- Direct Known Subclasses:
AmphibiousPathNavigation, FlyingPathNavigation, GroundPathNavigation, WaterBoundPathNavigation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the path can be changed byinvalid reference
onUpdateNavigation()private booleanprotected intprotected Vec3protected longprotected final Levelprivate static final intprotected floatprivate floatprotected final Mobprotected NodeEvaluatorprotected @Nullable Pathprivate final PathFinderprivate intDistance in which a path point counts as target-reachingprivate floatprotected doubleprivate static final intprivate static final floatprivate @Nullable BlockPosprotected intprotected longprotected Vec3iprotected doubleprotected long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCutCorner(PathType pathType) booleancanFloat()protected booleancanMoveDirectly(Vec3 startPos, Vec3 stopPos) Checks if the specified entity can safely walk to the specified location.abstract booleanprotected abstract booleanfinal @Nullable PathcreatePath(double x, double y, double z, int reachRange) Returns path to given BlockPos@Nullable PathcreatePath(Set<BlockPos> positions, int reachRange) protected @Nullable PathcreatePath(Set<BlockPos> targets, int radiusOffset, boolean above, int reachRange) Returns a path to one of the given targets or nullprotected @Nullable PathcreatePath(Set<BlockPos> targets, int radiusOffset, boolean above, int reachRange, float maxPathLength) @Nullable PathcreatePath(Stream<BlockPos> positions, int reachRange) Returns a path to one of the elements of the stream or null@Nullable PathcreatePath(BlockPos pos, int reachRange) Returns path to given BlockPos@Nullable PathcreatePath(BlockPos pos, int reachRange, int maxPathLength) @Nullable PathcreatePath(Entity target, int reachRange) Returns a path to the given entity or nullprotected abstract PathFindercreatePathFinder(int maxVisitedNodes) protected voiddoStuckDetection(Vec3 mobPos) Checks if entity haven't been moved when last checked and if so, stops the current navigation.protected voidprotected doublegetGroundY(Vec3 target) floatprivate float@Nullable PathgetPath()@Nullable BlockPosprotected abstract Vec3protected static booleanisClearForMovementBetween(Mob mob, Vec3 startPos, Vec3 stopPos, boolean blockedByFluids) booleanisDone()booleanbooleanbooleanisStuck()booleanmoveTo(double x, double y, double z, double speedModifier) Try to find and set a path to XYZ.booleanmoveTo(double x, double y, double z, int reachRange, double speedModifier) booleanTry to find and set a path to EntityLiving.booleanSets a new path.voidvoidprivate voidvoidsetCanFloat(boolean canFloat) voidsetCanOpenDoors(boolean canOpenDoors) voidsetMaxVisitedNodesMultiplier(float maxVisitedNodesMultiplier) voidsetRequiredPathLength(float length) voidsetSpeedModifier(double speedModifier) Sets the speedbooleanprivate booleanshouldTargetNextNodeInDirection(Vec3 mobPosition) voidstop()voidtick()private voidprotected voidtrimPath()void
-
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
-
level
-
path
-
speedModifier
protected double speedModifier -
tick
protected int tick -
lastStuckCheck
protected int lastStuckCheck -
lastStuckCheckPos
-
timeoutCachedNode
-
timeoutTimer
protected long timeoutTimer -
lastTimeoutCheck
protected long lastTimeoutCheck -
timeoutLimit
protected double timeoutLimit -
maxDistanceToWaypoint
protected float maxDistanceToWaypoint -
hasDelayedRecomputation
protected boolean hasDelayedRecomputationWhether the path can be changed byinvalid reference
onUpdateNavigation() -
timeLastRecompute
protected long timeLastRecompute -
nodeEvaluator
-
targetPos
-
reachRange
private int reachRangeDistance in which a path point counts as target-reaching -
maxVisitedNodesMultiplier
private float maxVisitedNodesMultiplier -
pathFinder
-
isStuck
private boolean isStuck -
requiredPathLength
private float requiredPathLength
-
-
Constructor Details
-
PathNavigation
-
-
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
-
createPathFinder
-
setSpeedModifier
public void setSpeedModifier(double speedModifier) Sets the speed -
recomputePath
public void recomputePath() -
createPath
Returns path to given BlockPos -
createPath
-
createPath
-
createPath
-
createPath
-
createPath
-
createPath
-
createPath
-
moveTo
public boolean moveTo(double x, double y, double z, double speedModifier) Try to find and set a path to XYZ. Returnstrueif successful. -
moveTo
public boolean moveTo(double x, double y, double z, int reachRange, double speedModifier) -
moveTo
Try to find and set a path to EntityLiving. Returnstrueif successful. -
moveTo
Sets a new path. If it's different from the old path. Checks to adjust path for sun avoiding, and stores start coords. -
getPath
-
tick
public void tick() -
getGroundY
-
followThePath
protected void followThePath() -
shouldTargetNextNodeInDirection
-
doStuckDetection
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
-
canUpdatePath
protected abstract boolean canUpdatePath() -
trimPath
protected void trimPath() -
canMoveDirectly
-
canCutCorner
-
isClearForMovementBetween
-
isStableDestination
-
getNodeEvaluator
-
setCanFloat
public void setCanFloat(boolean canFloat) -
canFloat
public boolean canFloat() -
shouldRecomputePath
-
getMaxDistanceToWaypoint
public float getMaxDistanceToWaypoint() -
isStuck
public boolean isStuck() -
setCanOpenDoors
public void setCanOpenDoors(boolean canOpenDoors)
-