Skip to content

PickupItemsGoal 5.47.0 ​

class · pocketmine\entity\ai\goal\PickupItemsGoal · source

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 ​

php
public const SEARCH_INTERVAL = 20

Ticks between two searches for items.

Properties ​

$canSearch ​

php
public \Closure $canSearch

$maxDistance ​

php
public float $maxDistance

$mob ​

php
public \pocketmine\entity\Mob $mob

$pickUp ​

php
public \Closure $pickUp

$speedMultiplier ​

php
public float $speedMultiplier

$wantsItem ​

php
public \Closure $wantsItem

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, \Closure $wantsItem, \Closure $pickUp, \Closure $canSearch, float $maxDistance = 3.0, float $speedMultiplier = 1.0)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

getFlags() ​

php
public function getFlags() : int

isAvailable() ​

php
public static function isAvailable(\pocketmine\entity\object\ItemEntity $entity) : bool

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

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.