Package com.destroystokyo.paper.entity
Interface Pathfinder
public interface Pathfinder
Handles pathfinding operations for an Entity
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Represents the result of a pathfinding calculation -
Method Summary
Modifier and TypeMethodDescriptionboolean
canFloat()
Checks if this pathfinder assumes that the mob can floatboolean
Checks if this pathfinder allows passing through closed doors.boolean
Checks if this pathfinder allows passing through open doors.findPath
(@NotNull LivingEntity target) Calculates a destination for the Entity to navigate to to reach the target entity, but does not set it as the current target.Calculates a destination for the Entity to navigate to, but does not set it as the current target.boolean
hasPath()
If the entity is currently trying to navigate to a destination, this will return truedefault boolean
Takes the result of a previous pathfinding calculation and sets it as the active pathfinding with default speed.boolean
moveTo
(@NotNull Pathfinder.PathResult path, double speed) Takes the result of a previous pathfinding calculation and sets it as the active pathfinding,default boolean
moveTo
(@NotNull LivingEntity target) Calculates a destination for the Entity to navigate to to reach the target entity, and sets it with default speed.default boolean
moveTo
(@NotNull LivingEntity target, double speed) Calculates a destination for the Entity to navigate to to reach the target entity, and sets it with specified speed.default boolean
Calculates a destination for the Entity to navigate to, and sets it with default speed as the current target.default boolean
Calculates a destination for the Entity to navigate to, with desired speed as the current target.void
setCanFloat
(boolean canFloat) Makes this pathfinder assume that the mob can float, or notvoid
setCanOpenDoors
(boolean canOpenDoors) Allows this pathfinder to pass through closed doors, or notvoid
setCanPassDoors
(boolean canPassDoors) Allows this pathfinder to pass through open doors, or notvoid
Instructs the Entity to stop trying to navigate to its current desired location
-
Method Details
-
getEntity
- Returns:
- The entity that is controlled by this pathfinder
-
stopPathfinding
void stopPathfinding()Instructs the Entity to stop trying to navigate to its current desired location -
hasPath
boolean hasPath()If the entity is currently trying to navigate to a destination, this will return true- Returns:
- true if the entity is navigating to a destination
-
getCurrentPath
- Returns:
- The location the entity is trying to navigate to, or null if there is no destination
-
findPath
Calculates a destination for the Entity to navigate to, but does not set it as the current target. Useful for calculating what would happen before setting it.- Parameters:
loc
- Location to navigate to- Returns:
- The closest Location the Entity can get to for this navigation, or null if no path could be calculated
-
findPath
Calculates a destination for the Entity to navigate to to reach the target entity, but does not set it as the current target. Useful for calculating what would happen before setting it. The behavior of this PathResult is subject to the games pathfinding rules, and may result in the pathfinding automatically updating to follow the target Entity. However, this behavior is not guaranteed, and is subject to the games behavior.- Parameters:
target
- the Entity to navigate to- Returns:
- The closest Location the Entity can get to for this navigation, or null if no path could be calculated
-
moveTo
Calculates a destination for the Entity to navigate to, and sets it with default speed as the current target.- Parameters:
loc
- Location to navigate to- Returns:
- If the pathfinding was successfully started
-
moveTo
Calculates a destination for the Entity to navigate to, with desired speed as the current target.- Parameters:
loc
- Location to navigate tospeed
- Speed multiplier to navigate at, where 1 is 'normal'- Returns:
- If the pathfinding was successfully started
-
moveTo
Calculates a destination for the Entity to navigate to to reach the target entity, and sets it with default speed. The behavior of this PathResult is subject to the games pathfinding rules, and may result in the pathfinding automatically updating to follow the target Entity. However, this behavior is not guaranteed, and is subject to the games behavior.- Parameters:
target
- the Entity to navigate to- Returns:
- If the pathfinding was successfully started
-
moveTo
Calculates a destination for the Entity to navigate to to reach the target entity, and sets it with specified speed. The behavior of this PathResult is subject to the games pathfinding rules, and may result in the pathfinding automatically updating to follow the target Entity. However, this behavior is not guaranteed, and is subject to the games behavior.- Parameters:
target
- the Entity to navigate tospeed
- Speed multiplier to navigate at, where 1 is 'normal'- Returns:
- If the pathfinding was successfully started
-
moveTo
Takes the result of a previous pathfinding calculation and sets it as the active pathfinding with default speed.- Parameters:
path
- The Path to start following- Returns:
- If the pathfinding was successfully started
-
moveTo
Takes the result of a previous pathfinding calculation and sets it as the active pathfinding,- Parameters:
path
- The Path to start followingspeed
- Speed multiplier to navigate at, where 1 is 'normal'- Returns:
- If the pathfinding was successfully started
-
canOpenDoors
boolean canOpenDoors()Checks if this pathfinder allows passing through closed doors.- Returns:
- if this pathfinder allows passing through closed doors
-
setCanOpenDoors
void setCanOpenDoors(boolean canOpenDoors) Allows this pathfinder to pass through closed doors, or not- Parameters:
canOpenDoors
- if the mob can pass through closed doors, or not
-
canPassDoors
boolean canPassDoors()Checks if this pathfinder allows passing through open doors.- Returns:
- if this pathfinder allows passing through open doors
-
setCanPassDoors
void setCanPassDoors(boolean canPassDoors) Allows this pathfinder to pass through open doors, or not- Parameters:
canPassDoors
- if the mob can pass through open doors, or not
-
canFloat
boolean canFloat()Checks if this pathfinder assumes that the mob can float- Returns:
- if this pathfinder assumes that the mob can float
-
setCanFloat
void setCanFloat(boolean canFloat) Makes this pathfinder assume that the mob can float, or not- Parameters:
canFloat
- if the mob can float, or not
-