Skip to content

Allay 5.46.0 ​

class · pocketmine\entity\animal\Allay · source

Extends Mob

Bedrock values (entities/allay.json): 20 health, 0.35x0.6, flies (flying speed 0.1). Give it an item and it keeps a copy in its hand, follows you (speed 8x, capped), collects matching item entities within 32 blocks (6x) into its one-stack inventory and drops them next to you when it's back within 3 blocks. Using an empty hand on it takes the held item (and the collected items) back. No drops other than its items; no XP. Note blocks: an allay with an item which hears a note block within 16 blocks (not through wool) brings its items to that note block instead and stays within 4 blocks of it, for 30 seconds after the last note (behavior.go_and_give_items_to_noteblock, behavior.stay_near_noteblock). Dancing: allays within 10 blocks of a jukebox which starts playing dance (DANCING flag) until the disc stops or they get farther than 10 blocks. Giving an amethyst shard to a dancing allay duplicates it (chime sound, hearts); both allays then wait 5 minutes before they can duplicate again (Java/Bedrock duplication cooldown, 6000 ticks).

Constants ​

DUPLICATION_COOLDOWN ​

php
public const DUPLICATION_COOLDOWN = 6000

JUKEBOX_RANGE ​

php
public const JUKEBOX_RANGE = 10.0

NOTE_BLOCK_MEMORY_TICKS ​

php
public const NOTE_BLOCK_MEMORY_TICKS = 600

NOTE_BLOCK_RANGE ​

php
public const NOTE_BLOCK_RANGE = 16.0

NOTE_BLOCK_STAY_DISTANCE ​

php
public const NOTE_BLOCK_STAY_DISTANCE = 4.0

Distance at which an allay stops approaching the note block it remembers (stay_near_noteblock).

TAG_DUPLICATION_COOLDOWN ​

php
public const TAG_DUPLICATION_COOLDOWN = "DuplicationCooldown"

TAG_HELD_ITEM ​

php
public const TAG_HELD_ITEM = "HeldItem"

TAG_INVENTORY ​

php
public const TAG_INVENTORY = "AllayInventory"

TAG_LIKED_PLAYER ​

php
public const TAG_LIKED_PLAYER = "LikedPlayer"

Methods ​

canBeLeashed() ​

php
public function canBeLeashed() : bool

canCollect() ​

php
public function canCollect(\pocketmine\item\Item $item) : bool

Whether the allay can take this item now (same item as the one in its hand, room left).

canDuplicate() ​

php
public function canDuplicate() : bool

collect() ​

php
public function collect(\pocketmine\entity\object\ItemEntity $entity) : void

duplicate() ​

php
public function duplicate() : \pocketmine\entity\animal\Allay

Splits the allay in two (a dancing allay was given an amethyst shard). The new allay holds nothing; both wait 5 minutes before duplicating again.

entityBaseTick() protected ​

php
protected function entityBaseTick(int $tickDiff = 1) : bool

findWantedItem() ​

php
public function findWantedItem() : ?\pocketmine\entity\object\ItemEntity

Nearest item entity matching the held item within 32 blocks, looked for once every second or so.

getCollectedItem() ​

php
public function getCollectedItem() : ?\pocketmine\item\Item

getDrops() ​

php
public function getDrops() : array

getDuplicationCooldown() ​

php
public function getDuplicationCooldown() : int

getFlyingSpeed() protected ​

php
protected function getFlyingSpeed() : float

getHeldItem() ​

php
public function getHeldItem() : ?\pocketmine\item\Item

getInitialSizeInfo() protected ​

php
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfo

getLikedPlayer() ​

php
public function getLikedPlayer() : ?\pocketmine\player\Player

getName() ​

php
public function getName() : string

getNetworkTypeId() ​

php
public static function getNetworkTypeId() : string

getNoteBlock() ​

php
public function getNoteBlock() : ?\pocketmine\math\Vector3

Note block the allay brings its items to, if it heard one in the last 30 seconds (and it is still there).

giveItemsTo() ​

php
public function giveItemsTo(\pocketmine\player\Player $player) : void

giveItemsToNoteBlock() ​

php
public function giveItemsToNoteBlock(\pocketmine\math\Vector3 $noteBlock) : void

Drops the collected items on the note block (the allay is next to it).

hearNoteBlock() ​

php
public function hearNoteBlock(\pocketmine\math\Vector3 $pos) : void

The allay heard the note block at the position: it brings its items there for the next 30 seconds.

initEntity() protected ​

php
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : void

isDancing() ​

php
public function isDancing() : bool

onDispose() protected ​

php
protected function onDispose() : void

onInteractWithItem() protected ​

php
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : bool

onJukeboxPlay() ​

php
public static function onJukeboxPlay(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : void

Called when a jukebox starts playing a disc: the allays within 10 blocks dance.

onNoteBlockPlayed() ​

php
public static function onNoteBlockPlayed(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : void

Called when a note block plays: allays holding an item within 16 blocks hear it, unless wool is in the way.

registerGoals() protected ​

php
protected function registerGoals() : void

saveNBT() ​

php
public function saveNBT() : \pocketmine\nbt\tag\CompoundTag

sendSpawnPacket() protected ​

php
protected function sendSpawnPacket(\pocketmine\player\Player $player) : void

setDuplicationCooldown() ​

php
public function setDuplicationCooldown(int $ticks) : void

startDancing() ​

php
public function startDancing(\pocketmine\math\Vector3 $jukebox) : void

Starts dancing to the jukebox at the position.

stopDancing() ​

php
public function stopDancing() : void

syncNetworkData() protected ​

php
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : void

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