Skip to content

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 ​

php
public const DEFAULT_MAX_NODES = 400

Methods ​

__construct() ​

php
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() ​

php
public function canOpenDoors() : bool

findPath() ​

php
public function findPath(int $sx, int $sy, int $sz, int $tx, int $ty, int $tz, float $acceptDistance = 0.0) : ?\pocketmine\entity\ai\navigation\Path

Finds a path from the block (sx, sy, sz) to the block (tx, ty, tz).

getLastVisitedCount() ​

php
public function getLastVisitedCount() : int

isStandable() ​

php
public function isStandable(int $x, int $y, int $z) : bool

Returns whether the mob can stand with its feet in the given block: fits() and something to stand on.

setCanOpenDoors() ​

php
public function setCanOpenDoors(bool $canOpenDoors) : void

Lets 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() ​

php
public function setMaxNodes(int $maxNodes) : void

setWorld() ​

php
public function setWorld(\pocketmine\world\World $world) : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.