-
Notifications
You must be signed in to change notification settings - Fork 1
Navigation_en
Originally I wanted to provide an interface to customize Navigation and even change its path-finding algorithm. but because the implementation was too verbose, we gave up. Due to time, the following navigation interface was rushed to use path-finding related algorithms.
FocessEntity provides #getNavigation() method to obtain Navigation instance.
` Navigation navigation = focessEntity.getNavigation(); `
With Navigation you can use path-finding related algorithms.
Use #getWorld() to get the world of the entity.
Note that all effective path-finding must be in one world
Use #isIdle () to get whether Navigation is idle or not to avoid simultaneous calls and not get the expected results.
Use #findPathTo(FocessEntity focessEntity)
To get the path to the entity
More convenient, you can use #findPathTo(double x, double y, double z) or #findPathTo(double x, double y, double z, int distance)
to get the path to the coordinates directly through the coordinate information of a certain world.
When you find the route, you can use #startMovingAlong(Path path, double speed)
to let the entity embark on a predetermined path.
Of course, you can also use #startMovingTo(final double x, final double y, final double z, final double speed) or #startMovingTo(final FocessEntity entity, final double speed)
to realize path-finding and action at the same time.
Use #getCurrentPath() to get the current path the navigation are using.
Use #stop() to stop this path-finding operation.
Use #getSpeed(), # getRangeMultiplier() to get speed and rangeMultiplier.
Use #setSpeed (double speed), #setRangeMultiplier (float rangeMultiplier) to set speed and rangeMultiplier.
Note that the default rangeMultiplier is float DEFAULT_RANGE_MULTIPLIER = 1.0F.
Use #recalculatePath () to recalculate the path.
Use #shouldRecalculatePath () to get whether the path needs to be recalculated.
Use #getAvoidsWater() (only for 1.8), #canOpenDoors() (not for 1.8),
avoidSunlight(), #canEnterOpenDoors(),
#canSwim()
Get related path-finding restrictions.
Use #setAvoidsWater(boolean avoidsWater) (only for 1.8), #setCanOpenDoors(final boolean canOpenDoors) (not for 1.8),
#setAvoidSunlight(final boolean avoidSunlight), #setCanEnterOpenDoors(final boolean canEnterOpenDoors),
#setCanSwim(final boolean canSwim)
Modify related path-finding restrictions.