Im basically trying to implement Pathfinders like Bukkit into Pocketmine but im running into problems like how to activate the code everytime the server ticks the entity: PHP: interface Pathfinder{ public function tick() : bool(); public function execute();} PHP: class PathfinderExample implements Pathfinder{ private $entity; public function __construct(Creature $entity){ $this->entity = $entity; } public function tick() : bool{ if(/*Condition met*/){ return true; } else { return false; } } public function execute{ /*Do stuff*/ }} Does anyone know where the code that ticks the entities is?
make your plugin extend the entity and then use entityBaseTick: Example for a Zombie (basically every Monster/Creature/Living or Entity which doesn't change constructor things) PHP: class Pathfinder extends Entitiy{ public function __construct(Level $level, CompoundTag $nbt){ parent::__construct($level, $nbt); } public function entityBaseTick() : bool{ if(/*Condition met*/){ return true; }else{ return false; } } public function execute{ /*Do stuff*/ }}
Mmm well im trying to make a pathfinder... not just create attack functions in the class... Unless thats a reference?
PHP: class Wither extends Monster{ /*Left out all the parts unimportant like getName() entity id And the width and height*/ private $goalSelector = new PathfinderSelector(); public function __construct(Level $level, Compound $nbt){ parent::__construct($level, $nbt); $this->goalSelector->register(new PathfinderActPassive($this)); }} It keeps throwing some squiggly error i cant read...
Err well i did but... i made the PathfinderSelector and used it like the NMS for PC Servers does which does the same thing... Also i cant really figure that out cause then the Pathfinder would be an Entity itself..?