PathFinder 5.46.0
final class · pocketmine\entity\ai\navigation\PathFinder · source
A* over the block grid for walking mobs.
A node is the block a mob's feet are in. A node is standable when the mob fits (feet and head blocks passable), the block below is a floor (or the feet block is a low block like a slab, or water when the mob swims), and neither is dangerous (fire, lava, cactus...). From a node the mob can walk to the 8 neighbours on the same level, step/jump up one block, or drop down up to PathFinder::$maxDrop blocks. Diagonal moves can't cut corners.
Searches are bounded by a node limit; when the target can't be reached the path to the explored node closest to it is returned (like vanilla), so mobs at least move towards it.
Constants
DEFAULT_MAX_NODES
public const DEFAULT_MAX_NODES = 400Methods
__construct()
public function __construct(\pocketmine\world\World $world, int $headBlocks = 1, int $maxDrop = 3, bool $canSwim = true, bool $avoidWater = false, int $maxNodes = self::DEFAULT_MAX_NODES)canOpenDoors()
public function canOpenDoors() : boolfindPath()
public function findPath(int $sx, int $sy, int $sz, int $tx, int $ty, int $tz, float $acceptDistance = 0.0) : ?\pocketmine\entity\ai\navigation\PathFinds a path from the block (sx, sy, sz) to the block (tx, ty, tz).
getLastVisitedCount()
public function getLastVisitedCount() : intisStandable()
public function isStandable(int $x, int $y, int $z) : boolReturns whether the mob can stand with its feet in the given block: fits() and something to stand on.
setCanOpenDoors()
public function setCanOpenDoors(bool $canOpenDoors) : voidLets the paths go through closed doors other than iron doors (villagers open them, vanilla navigation can_open_doors). These searches run in PHP: the native finder classifies block states once for all mobs.
setMaxNodes()
public function setMaxNodes(int $maxNodes) : voidsetWorld()
public function setWorld(\pocketmine\world\World $world) : void