Allay 5.46.0
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
public const DUPLICATION_COOLDOWN = 6000JUKEBOX_RANGE
public const JUKEBOX_RANGE = 10.0NOTE_BLOCK_MEMORY_TICKS
public const NOTE_BLOCK_MEMORY_TICKS = 600NOTE_BLOCK_RANGE
public const NOTE_BLOCK_RANGE = 16.0NOTE_BLOCK_STAY_DISTANCE
public const NOTE_BLOCK_STAY_DISTANCE = 4.0Distance at which an allay stops approaching the note block it remembers (stay_near_noteblock).
TAG_DUPLICATION_COOLDOWN
public const TAG_DUPLICATION_COOLDOWN = "DuplicationCooldown"TAG_HELD_ITEM
public const TAG_HELD_ITEM = "HeldItem"TAG_INVENTORY
public const TAG_INVENTORY = "AllayInventory"TAG_LIKED_PLAYER
public const TAG_LIKED_PLAYER = "LikedPlayer"Methods
canBeLeashed()
public function canBeLeashed() : boolcanCollect()
public function canCollect(\pocketmine\item\Item $item) : boolWhether the allay can take this item now (same item as the one in its hand, room left).
canDuplicate()
public function canDuplicate() : boolcollect()
public function collect(\pocketmine\entity\object\ItemEntity $entity) : voidduplicate()
public function duplicate() : \pocketmine\entity\animal\AllaySplits 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
protected function entityBaseTick(int $tickDiff = 1) : boolfindWantedItem()
public function findWantedItem() : ?\pocketmine\entity\object\ItemEntityNearest item entity matching the held item within 32 blocks, looked for once every second or so.
getCollectedItem()
public function getCollectedItem() : ?\pocketmine\item\ItemgetDrops()
public function getDrops() : arraygetDuplicationCooldown()
public function getDuplicationCooldown() : intgetFlyingSpeed() protected
protected function getFlyingSpeed() : floatgetHeldItem()
public function getHeldItem() : ?\pocketmine\item\ItemgetInitialSizeInfo() protected
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfogetLikedPlayer()
public function getLikedPlayer() : ?\pocketmine\player\PlayergetName()
public function getName() : stringgetNetworkTypeId()
public static function getNetworkTypeId() : stringgetNoteBlock()
public function getNoteBlock() : ?\pocketmine\math\Vector3Note block the allay brings its items to, if it heard one in the last 30 seconds (and it is still there).
giveItemsTo()
public function giveItemsTo(\pocketmine\player\Player $player) : voidgiveItemsToNoteBlock()
public function giveItemsToNoteBlock(\pocketmine\math\Vector3 $noteBlock) : voidDrops the collected items on the note block (the allay is next to it).
hearNoteBlock()
public function hearNoteBlock(\pocketmine\math\Vector3 $pos) : voidThe allay heard the note block at the position: it brings its items there for the next 30 seconds.
initEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisDancing()
public function isDancing() : boolonDispose() protected
protected function onDispose() : voidonInteractWithItem() protected
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : boolonJukeboxPlay()
public static function onJukeboxPlay(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : voidCalled when a jukebox starts playing a disc: the allays within 10 blocks dance.
onNoteBlockPlayed()
public static function onNoteBlockPlayed(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : voidCalled when a note block plays: allays holding an item within 16 blocks hear it, unless wool is in the way.
registerGoals() protected
protected function registerGoals() : voidsaveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsendSpawnPacket() protected
protected function sendSpawnPacket(\pocketmine\player\Player $player) : voidsetDuplicationCooldown()
public function setDuplicationCooldown(int $ticks) : voidstartDancing()
public function startDancing(\pocketmine\math\Vector3 $jukebox) : voidStarts dancing to the jukebox at the position.
stopDancing()
public function stopDancing() : voidsyncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : void