Skip to content

Navigation_en

MidCoard edited this page Mar 27, 2020 · 1 revision

Use Navigation

Start

Write in front

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.

Navigation

Get Navigation

FocessEntity provides #getNavigation() method to obtain Navigation instance.

` Navigation navigation = focessEntity.getNavigation(); `

With Navigation you can use path-finding related algorithms.

Get the world

Use #getWorld() to get the world of the entity.

Note that all effective path-finding must be in one world

start using

Use #isIdle () to get whether Navigation is idle or not to avoid simultaneous calls and not get the expected results.

Find your way to the entity

Use #findPathTo(FocessEntity focessEntity) To get the path to the entity

Find a route

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.

Let's move

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.

Get path

Use #getCurrentPath() to get the current path the navigation are using.

Interrupted action

Use #stop() to stop this path-finding operation.

Speed ​​and error range correction

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.

Recalculate the path

Use #recalculatePath () to recalculate the path.

Use #shouldRecalculatePath () to get whether the path needs to be recalculated.

Get and modify some path-finding restrictions

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.

开始(Getting Started)

实体处理(Deal with Entity)

Goal操作(Modify Goal)

使用Navigation(Use Navigation)

其他(Other Things)

Clone this wiki locally