AbstractHorse 5.46.0
Extends TameableAnimal
Implements MountInventoryHolder
Horses, donkeys, mules, llamas, skeleton and zombie horses.
Health, speed and jump strength are random per animal (Bedrock "range_min"/"range_max") and babies get the average of their parents plus a random part (Java rule). Food heals and makes babies grow by vanilla amounts.
Riding: using an adult with an empty hand (or any non-food item once tamed) mounts it (seat 1.1 up and 0.2 back for horses). An untamed one is broken in by riding it (vanilla tamemount, Java RunAroundLikeCrazyGoal): it runs around, and every tick has a 1 in 50 chance to either get tamed (a random number below 100 under its temper) or throw the rider off and raise its temper by 5; food raises the temper too. A saddle can be put on a tamed animal (SADDLED flag, dropped on death); saddled, it is steered by its rider (WASD_CONTROLLED, CAN_POWER_JUMP: the client shows the jump bar). Clients predict the movement of these vehicles in server-authoritative movement and send it with PlayerAuthInputPacket; without that the server moves it (speed: movement attribute x 2.1 blocks per tick, jumps charged by holding jump for up to 10 ticks, Java formula). Fall damage is halved minus 3 (Java). A wild one may carry a baby zombie jockey and walks to its target (vanilla behavior.mount_pathing).
Inventory (HorseInventory, vanilla "horse" container): the saddle (or a llama's carpet), the horse armor of the animals that wear it and the chest of donkeys, mules and llamas. A tamed adult's inventory opens when a player sneaks and uses it, or when its rider presses the inventory button (InteractPacket OPEN_INVENTORY); viewers farther than 8 blocks get it closed (Java). Saddles, horse armor, carpets and chests are also put on by using them on a tamed adult. A chest can't be taken off (only dropped on death, with everything in the inventory). The contents are saved like Bedrock's container component ("ChestItems", "Chested"). Horse armor protects like armor (vanilla protection points) and, like a llama's carpet, is shown to viewers in the body slot of MobArmorEquipmentPacket.
Constants
CHEST_SIZE
public const CHEST_SIZE = 15Chest slots of a chested donkey or mule (vanilla inventory_size 16, minus the saddle slot).
MAX_TEMPER
public const MAX_TEMPER = 100TAG_CHESTED
public const TAG_CHESTED = "Chested"TAG_CHEST_ITEMS
public const TAG_CHEST_ITEMS = "ChestItems"TAG_JUMP_STRENGTH
public const TAG_JUMP_STRENGTH = "JumpStrength"TAG_MAX_HEALTH
public const TAG_MAX_HEALTH = "HorseMaxHealth"TAG_SADDLED
public const TAG_SADDLED = "Saddled"TAG_SPEED
public const TAG_SPEED = "HorseSpeed"TAG_TEMPER
public const TAG_TEMPER = "Temper"Properties
$inventory protected
protected \pocketmine\inventory\HorseInventory $inventory$jumpStrength protected
protected float $jumpStrength$temper protected
protected int $temperMethods
acceptsInEquipSlot() protected
protected function acceptsInEquipSlot(\pocketmine\item\Item $item) : boolWhether the item goes in slot 0 of the inventory: a saddle, for the animals that wear one.
addAttributes() protected
protected function addAttributes() : voidcalculateFallDamage() protected
protected function calculateFallDamage(float $fallDistance) : floatcanBeRiddenBy()
public function canBeRiddenBy(\pocketmine\entity\Entity $entity) : boolcanBeSteeredBy()
public function canBeSteeredBy(\pocketmine\player\Player $rider) : boolcanHaveChest()
public function canHaveChest() : boolWhether a chest can be put on the animal (donkeys, mules and llamas).
canHoldInSlot()
public function canHoldInSlot(int $slot, \pocketmine\item\Item $item) : boolReturns whether the item may be put in the given slot of the inventory: a saddle in the saddle slot (a carpet for llamas, see AbstractHorse::acceptsInEquipSlot()), horse armor in the armor slot, anything in the chest.
canOpenInventory()
public function canOpenInventory(\pocketmine\player\Player $player) : boolWhether the player may open the inventory (a tamed adult, or one that needs no taming).
canWearSaddle()
public function canWearSaddle() : boolWhether a saddle can be put on it (llamas can't take one).
entityBaseTick() protected
protected function entityBaseTick(int $tickDiff = 1) : boolgetAdultDrops() protected
protected function getAdultDrops() : arraygetArmorPoints()
public function getArmorPoints() : intgetArmorSlotIcon()
public function getArmorSlotIcon() : stringgetArmorSlotItemNames()
public function getArmorSlotItemNames() : arraygetBodyItem()
public function getBodyItem() : \pocketmine\item\ItemThe item shown on the animal's body (the body slot of MobArmorEquipmentPacket): horse armor, or a llama's carpet.
getChestSize()
public function getChestSize() : intNumber of slots of the animal's chest (donkeys and mules: 15; llamas: 3 per strength).
getContainerBaseSize() protected
protected function getContainerBaseSize() : intVanilla inventory_size of the container component (horses 2, chested animals 16).
getContainerSlotsPerStrength() protected
protected function getContainerSlotsPerStrength() : intVanilla additional_slots_per_strength of the container component (llamas 3).
getDrops()
public function getDrops() : arraygetEquipSound() protected
protected function getEquipSound(int $slot, \pocketmine\item\Item $item) : stringThe sound of putting the item in the saddle or armor slot.
getFeedGrowth() protected
protected function getFeedGrowth(\pocketmine\item\Item $item) : intgetFood() protected
protected function getFood(\pocketmine\item\Item $item) : ?arrayReturns [heal, growth, temper] for a food item, or null if the animal doesn't eat it.
getHorseArmor()
public function getHorseArmor() : \pocketmine\item\ItemReturns the horse armor worn (air for the animals that don't wear armor).
getInventory()
public function getInventory() : \pocketmine\inventory\HorseInventorygetInventorySize()
public function getInventorySize() : intNumber of slots of the inventory: the saddle (or carpet) slot, the armor slot of the animals that wear armor and the chest slots of a chested one.
getItemInteractButtonText() protected
protected function getItemInteractButtonText(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : ?stringgetJumpStrength()
public function getJumpStrength() : floatgetRiddenSpeed() protected
protected function getRiddenSpeed(\pocketmine\player\Player $rider) : floatgetRideInteractText() protected
protected function getRideInteractText() : stringgetRideableSeats()
public function getRideableSeats() : arraygetRiderSeat() protected
protected function getRiderSeat() : \pocketmine\entity\riding\RideableSeatThe seat of the rider (vanilla rideable component).
getTemper()
public function getTemper() : intgetXpDropAmount()
public function getXpDropAmount() : inthasArmorSlot()
public function hasArmorSlot() : boolWhether the animal wears horse armor (horses and zombie horses).
inheritStats() protected
protected function inheritStats(\pocketmine\entity\animal\AbstractHorse $baby, \pocketmine\entity\animal\Animal $partner) : voidGives a baby the average of the parents' stats plus a random part, like Java.
initEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisBeingBrokenIn()
public function isBeingBrokenIn() : boolReturns whether a player rides the untamed animal to tame it.
isBreedingItem()
public function isBreedingItem(\pocketmine\item\Item $item) : boolisChested()
public function isChested() : boolisDrivenByRiderClient() protected
protected function isDrivenByRiderClient() : boolisHorseArmor()
public static function isHorseArmor(\pocketmine\item\Item $item) : boolisSaddled()
public function isSaddled() : boolisTameable()
public function isTameable() : boolWhether the animal can be tamed at all (skeleton and zombie horses can't).
isTemptItem() protected
protected function isTemptItem(\pocketmine\item\Item $item) : boolItems that lure the animal (horses: golden apples and carrots).
onDeath() protected
protected function onDeath() : voidonDispose() protected
protected function onDispose() : voidonInteractWithItem() protected
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : boolonInventorySlotChange() protected
protected function onInventorySlotChange(int $slot, \pocketmine\item\Item $before) : voidCalled when a slot of the inventory changed (through the screen, an interaction or a plugin).
onRiderJump() protected
protected function onRiderJump(float $power) : voidJumps with the given power (0.4 to 1) when the rider releases the jump button (server-moved horses only).
openInventory()
public function openInventory(\pocketmine\player\Player $player) : boolOpens the inventory to the player. Returns whether it opened.
randomRange() protected
protected static function randomRange(float $min, float $max) : floatRandom value between $min and $max.
randomStats() protected
abstract protected function randomStats() : arrayRandom stats of a new animal: [max health, movement speed, jump strength].
registerGoals() protected
protected function registerGoals() : voidresizeInventory() protected
protected function resizeInventory() : voidReplaces the inventory with one of the size the animal needs now (after a chest is put on, or a llama's strength changed), closing it for its viewers. Items that don't fit any more are dropped.
saveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsendSpawnPacket() protected
protected function sendSpawnPacket(\pocketmine\player\Player $player) : voidsetChested()
public function setChested(bool $chested) : voidPuts a chest on the animal or takes it off (the contents of the chest that no longer fit are dropped).
setHorseArmor()
public function setHorseArmor(\pocketmine\item\Item $armor) : voidsetJumpStrength()
public function setJumpStrength(float $strength) : voidsetSaddled()
public function setSaddled(bool $saddled) : voidPuts a saddle in the saddle slot, or empties it.
setTemper()
public function setTemper(int $temper) : voidsteer() protected
protected function steer(\pocketmine\player\Player $rider, \pocketmine\entity\riding\RiderInput $input) : voidsyncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : voidtryMount()
public function tryMount(\pocketmine\player\Player $player) : boolMakes the player ride the animal (breaking it in if it isn't tamed, see the class doc). Returns whether the player got on.
