Skip to content

TameableAnimal 5.46.0 ​

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

Extends Animal

An animal that a player can tame (wolves, cats, parrots, horses...). A tamed animal has an owner, can be ordered to sit, and its owner is shown to clients (OWNER_EID, TAMED and SITTING flags).

The owner is saved by UUID ("OwnerUUID", PocketMine-specific: vanilla saves the owner's actor unique ID, which PocketMine doesn't keep across sessions).

Constants ​

TAG_OWNER_UUID ​

php
public const TAG_OWNER_UUID = "OwnerUUID"

TAG_SITTING ​

php
public const TAG_SITTING = "Sitting"

TAG_TAMED ​

php
public const TAG_TAMED = "IsTamed"

Properties ​

$ownerUuid protected ​

php
protected ?\Ramsey\Uuid\UuidInterface $ownerUuid

$sitting protected ​

php
protected bool $sitting

Methods ​

canFallInLove() protected ​

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

canMate() ​

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

getOwner() ​

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

Returns the owner if it is online and in the same world.

getOwnerUuid() ​

php
public function getOwnerUuid() : ?\Ramsey\Uuid\UuidInterface

initEntity() protected ​

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

isOwner() ​

php
public function isOwner(\pocketmine\entity\Living $entity) : bool

isSitting() ​

php
public function isSitting() : bool

isTamed() ​

php
public function isTamed() : bool

onDispose() protected ​

php
protected function onDispose() : void

onTamedChanged() protected ​

php
protected function onTamedChanged() : void

Called when the animal is tamed or untamed (health and goals of tamed wolves and cats change).

requiresTameToBreed() protected ​

php
protected function requiresTameToBreed() : bool

Whether only tamed animals of this kind breed (wolves, cats, llamas, horses).

saveNBT() ​

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

setAttackTarget() ​

php
public function setAttackTarget(?\pocketmine\entity\Living $target) : void

setOwner() ​

php
public function setOwner(?\pocketmine\player\Player $owner) : void

Tames the animal for the player (no chance roll, no particles).

setSitting() ​

php
public function setSitting(bool $sitting) : void

syncNetworkData() protected ​

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

tryTame() ​

php
public function tryTame(\pocketmine\player\Player $player, float $chance) : bool

Feeding attempt with a taming item: succeeds with the given chance (vanilla 1/3). Shows hearts or smoke. Returns whether the animal was tamed.

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