PickupItemsGoal 5.47.0
Extends Goal
Walks to an item lying on the ground that the mob wants and picks it up (vanilla behavior.pickup_items): the nearest wanted item within $maxDistance blocks, looked for once a second and only while $canSearch allows it (e.g. the mob can pick up loot and mobGriefing is on). Items nobody may pick up yet (pickup delay, including the infinite delay of display items) are ignored. The paths to items are short (an item is a few blocks away): an item the mob can't reach (no such path, or not reached in 5 seconds) is left alone for 30 seconds, and the next search waits 5 seconds, so mobs next to items behind walls or glass don't keep searching paths to them.
$wantsItem tells whether the mob wants an item (e.g. shareables), $pickUp takes the item when the mob touches it and returns whether it did.
Constants
SEARCH_INTERVAL
public const SEARCH_INTERVAL = 20Ticks between two searches for items.
Properties
$canSearch
public \Closure $canSearch$maxDistance
public float $maxDistance$mob
public \pocketmine\entity\Mob $mob$pickUp
public \Closure $pickUp$speedMultiplier
public float $speedMultiplier$wantsItem
public \Closure $wantsItemMethods
__construct()
public function __construct(\pocketmine\entity\Mob $mob, \Closure $wantsItem, \Closure $pickUp, \Closure $canSearch, float $maxDistance = 3.0, float $speedMultiplier = 1.0)canContinue()
public function canContinue() : boolcanStart()
public function canStart() : boolgetFlags()
public function getFlags() : intisAvailable()
public static function isAvailable(\pocketmine\entity\object\ItemEntity $entity) : boolWhether a mob may pick the item entity up now: not despawning and with no pickup delay (an infinite delay (ItemEntity::NEVER_DESPAWN) marks items nobody may take, like the display items of plugins).
start()
public function start() : voidstop()
public function stop() : voidtick()
public function tick() : void