Animal 5.46.0
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
public const BABY_AGE = -24000BREED_COOLDOWN
public const BREED_COOLDOWN = 6000LOVE_TICKS
public const LOVE_TICKS = 600TAG_AGE
public const TAG_AGE = "Age"TAG_IN_LOVE
public const TAG_IN_LOVE = "InLove"TAG_IS_BABY
public const TAG_IS_BABY = "IsBaby"Properties
$age protected
protected int $age$inLove protected
protected int $inLoveMethods
ageUp()
public function ageUp(int $ticks) : voidMakes a baby grow by the given number of ticks.
breed()
public function breed(\pocketmine\entity\animal\Animal $partner) : ?\pocketmine\entity\animal\AnimalSpawns 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
protected function breedsWith(\pocketmine\entity\animal\Animal $other) : boolReturns 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()
public function broadcastActorEvent(int $event, int $data = 0) : voidcanBeLeashed()
public function canBeLeashed() : boolAnimals can be led with a lead (vanilla: all of them except villagers).
canFallInLove() protected
protected function canFallInLove(\pocketmine\player\Player $player) : boolReturns whether feeding the breeding item may put this adult in love now (e.g. only tamed wolves at full health).
canMate()
public function canMate(\pocketmine\entity\animal\Animal $other) : boolReturns whether this animal can mate with the other one right now.
consumeFood() protected
protected function consumeFood(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : voidTakes the food fed to the animal from the player's hand. Bucket foods (axolotls, nautiluses) leave a water bucket.
cookedIfBurning() protected
protected function cookedIfBurning(\pocketmine\item\Item $raw, \pocketmine\item\Item $cooked) : \pocketmine\item\ItemReturns the raw or cooked version of a meat drop depending on whether the animal died burning.
createBaby() protected
abstract protected function createBaby(\pocketmine\entity\animal\Animal $partner, \pocketmine\entity\Location $location) : \pocketmine\entity\animal\AnimalCreates (without spawning) the baby of this animal and the partner.
entityBaseTick() protected
protected function entityBaseTick(int $tickDiff = 1) : boolgetAdultDrops() protected
protected function getAdultDrops() : arraygetAdultScale() protected
protected function getAdultScale() : floatScale of the adult (Bedrock "minecraft:scale"; the collision box is scaled with it).
getAge()
public function getAge() : intgetBabyScale() protected
protected function getBabyScale() : floatScale of the baby (Bedrock "minecraft:scale" of the baby component group).
getDrops()
public function getDrops() : arraygetFeedGrowth() protected
protected function getFeedGrowth(\pocketmine\item\Item $item) : intReturns how many ticks of growing up feeding this item to a baby saves (vanilla: 10% of the remaining time).
getLoveTicks()
public function getLoveTicks() : intgetXpDropAmount()
public function getXpDropAmount() : intinitEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisBaby()
public function isBaby() : boolisBreedingItem()
abstract public function isBreedingItem(\pocketmine\item\Item $item) : boolReturns whether the item is the food that makes this animal breed (and lures it, and makes babies grow).
isInLove()
public function isInLove() : boolonGrowUp() protected
protected function onGrowUp() : voidCalled when the baby becomes an adult.
onInteractWithItem() protected
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : boolsaveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsetAge()
public function setAge(int $age) : voidsetInLove()
public function setInLove(int $ticks) : voidspawnBaby() protected
protected function spawnBaby(\pocketmine\entity\animal\Animal $partner) : ?\pocketmine\entity\animal\AnimalCreates and spawns the baby when two animals breed. Animals that lay eggs override this to become pregnant and return null.
syncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : void