Skip to content

Animal 5.46.0 ​

abstract class · pocketmine\entity\animal\Animal · source

Extends Mob
Implements Ageable

A passive animal that can be bred with food and has babies which grow up.

Age follows vanilla: negative = baby (grows up at 0, after 20 minutes), positive = breeding cooldown (5 minutes). Feeding the breeding food to an adult puts it in love for 30 seconds; feeding a baby takes 10% off its remaining growing time.

Constants ​

BABY_AGE ​

php
public const BABY_AGE = -24000

BREED_COOLDOWN ​

php
public const BREED_COOLDOWN = 6000

LOVE_TICKS ​

php
public const LOVE_TICKS = 600

TAG_AGE ​

php
public const TAG_AGE = "Age"

TAG_IN_LOVE ​

php
public const TAG_IN_LOVE = "InLove"

TAG_IS_BABY ​

php
public const TAG_IS_BABY = "IsBaby"

Properties ​

$age protected ​

php
protected int $age

$inLove protected ​

php
protected int $inLove

Methods ​

ageUp() ​

php
public function ageUp(int $ticks) : void

Makes a baby grow by the given number of ticks.

breed() ​

php
public function breed(\pocketmine\entity\animal\Animal $partner) : ?\pocketmine\entity\animal\Animal

Spawns a baby of the two animals, resets their love and starts their breeding cooldown. Returns the baby, or null if the animal became pregnant instead (frogs, turtles, sniffers lay eggs later).

breedsWith() protected ​

php
protected function breedsWith(\pocketmine\entity\animal\Animal $other) : bool

Returns whether this kind of animal breeds with the other one's kind (Bedrock "breeds_with"): by default the same kind only; horses also breed with donkeys, llamas with trader llamas.

broadcastActorEvent() ​

php
public function broadcastActorEvent(int $event, int $data = 0) : void

canBeLeashed() ​

php
public function canBeLeashed() : bool

Animals can be led with a lead (vanilla: all of them except villagers).

canFallInLove() protected ​

php
protected function canFallInLove(\pocketmine\player\Player $player) : bool

Returns whether feeding the breeding item may put this adult in love now (e.g. only tamed wolves at full health).

canMate() ​

php
public function canMate(\pocketmine\entity\animal\Animal $other) : bool

Returns whether this animal can mate with the other one right now.

consumeFood() protected ​

php
protected function consumeFood(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : void

Takes the food fed to the animal from the player's hand. Bucket foods (axolotls, nautiluses) leave a water bucket.

cookedIfBurning() protected ​

php
protected function cookedIfBurning(\pocketmine\item\Item $raw, \pocketmine\item\Item $cooked) : \pocketmine\item\Item

Returns the raw or cooked version of a meat drop depending on whether the animal died burning.

createBaby() protected ​

php
abstract protected function createBaby(\pocketmine\entity\animal\Animal $partner, \pocketmine\entity\Location $location) : \pocketmine\entity\animal\Animal

Creates (without spawning) the baby of this animal and the partner.

entityBaseTick() protected ​

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

getAdultDrops() protected ​

php
protected function getAdultDrops() : array

getAdultScale() protected ​

php
protected function getAdultScale() : float

Scale of the adult (Bedrock "minecraft:scale"; the collision box is scaled with it).

getAge() ​

php
public function getAge() : int

getBabyScale() protected ​

php
protected function getBabyScale() : float

Scale of the baby (Bedrock "minecraft:scale" of the baby component group).

getDrops() ​

php
public function getDrops() : array

getFeedGrowth() protected ​

php
protected function getFeedGrowth(\pocketmine\item\Item $item) : int

Returns how many ticks of growing up feeding this item to a baby saves (vanilla: 10% of the remaining time).

getLoveTicks() ​

php
public function getLoveTicks() : int

getXpDropAmount() ​

php
public function getXpDropAmount() : int

initEntity() protected ​

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

isBaby() ​

php
public function isBaby() : bool

isBreedingItem() ​

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

Returns whether the item is the food that makes this animal breed (and lures it, and makes babies grow).

isInLove() ​

php
public function isInLove() : bool

onGrowUp() protected ​

php
protected function onGrowUp() : void

Called when the baby becomes an adult.

onInteractWithItem() protected ​

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

saveNBT() ​

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

setAge() ​

php
public function setAge(int $age) : void

setInLove() ​

php
public function setInLove(int $ticks) : void

spawnBaby() protected ​

php
protected function spawnBaby(\pocketmine\entity\animal\Animal $partner) : ?\pocketmine\entity\animal\Animal

Creates and spawns the baby when two animals breed. Animals that lay eggs override this to become pregnant and return null.

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.