Skip to content

AbstractHorse 5.46.0 ​

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

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 ​

php
public const CHEST_SIZE = 15

Chest slots of a chested donkey or mule (vanilla inventory_size 16, minus the saddle slot).

MAX_TEMPER ​

php
public const MAX_TEMPER = 100

TAG_CHESTED ​

php
public const TAG_CHESTED = "Chested"

TAG_CHEST_ITEMS ​

php
public const TAG_CHEST_ITEMS = "ChestItems"

TAG_JUMP_STRENGTH ​

php
public const TAG_JUMP_STRENGTH = "JumpStrength"

TAG_MAX_HEALTH ​

php
public const TAG_MAX_HEALTH = "HorseMaxHealth"

TAG_SADDLED ​

php
public const TAG_SADDLED = "Saddled"

TAG_SPEED ​

php
public const TAG_SPEED = "HorseSpeed"

TAG_TEMPER ​

php
public const TAG_TEMPER = "Temper"

Properties ​

$inventory protected ​

php
protected \pocketmine\inventory\HorseInventory $inventory

$jumpStrength protected ​

php
protected float $jumpStrength

$temper protected ​

php
protected int $temper

Methods ​

acceptsInEquipSlot() protected ​

php
protected function acceptsInEquipSlot(\pocketmine\item\Item $item) : bool

Whether the item goes in slot 0 of the inventory: a saddle, for the animals that wear one.

addAttributes() protected ​

php
protected function addAttributes() : void

calculateFallDamage() protected ​

php
protected function calculateFallDamage(float $fallDistance) : float

canBeRiddenBy() ​

php
public function canBeRiddenBy(\pocketmine\entity\Entity $entity) : bool

canBeSteeredBy() ​

php
public function canBeSteeredBy(\pocketmine\player\Player $rider) : bool

canHaveChest() ​

php
public function canHaveChest() : bool

Whether a chest can be put on the animal (donkeys, mules and llamas).

canHoldInSlot() ​

php
public function canHoldInSlot(int $slot, \pocketmine\item\Item $item) : bool

Returns 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() ​

php
public function canOpenInventory(\pocketmine\player\Player $player) : bool

Whether the player may open the inventory (a tamed adult, or one that needs no taming).

canWearSaddle() ​

php
public function canWearSaddle() : bool

Whether a saddle can be put on it (llamas can't take one).

entityBaseTick() protected ​

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

getAdultDrops() protected ​

php
protected function getAdultDrops() : array

getArmorPoints() ​

php
public function getArmorPoints() : int

getArmorSlotIcon() ​

php
public function getArmorSlotIcon() : string

getArmorSlotItemNames() ​

php
public function getArmorSlotItemNames() : array

getBodyItem() ​

php
public function getBodyItem() : \pocketmine\item\Item

The item shown on the animal's body (the body slot of MobArmorEquipmentPacket): horse armor, or a llama's carpet.

getChestSize() ​

php
public function getChestSize() : int

Number of slots of the animal's chest (donkeys and mules: 15; llamas: 3 per strength).

getContainerBaseSize() protected ​

php
protected function getContainerBaseSize() : int

Vanilla inventory_size of the container component (horses 2, chested animals 16).

getContainerSlotsPerStrength() protected ​

php
protected function getContainerSlotsPerStrength() : int

Vanilla additional_slots_per_strength of the container component (llamas 3).

getDrops() ​

php
public function getDrops() : array

getEquipSound() protected ​

php
protected function getEquipSound(int $slot, \pocketmine\item\Item $item) : string

The sound of putting the item in the saddle or armor slot.

getFeedGrowth() protected ​

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

getFood() protected ​

php
protected function getFood(\pocketmine\item\Item $item) : ?array

Returns [heal, growth, temper] for a food item, or null if the animal doesn't eat it.

getHorseArmor() ​

php
public function getHorseArmor() : \pocketmine\item\Item

Returns the horse armor worn (air for the animals that don't wear armor).

getInventory() ​

php
public function getInventory() : \pocketmine\inventory\HorseInventory

getInventorySize() ​

php
public function getInventorySize() : int

Number 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 ​

php
protected function getItemInteractButtonText(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : ?string

getJumpStrength() ​

php
public function getJumpStrength() : float

getRiddenSpeed() protected ​

php
protected function getRiddenSpeed(\pocketmine\player\Player $rider) : float

getRideInteractText() protected ​

php
protected function getRideInteractText() : string

getRideableSeats() ​

php
public function getRideableSeats() : array

getRiderSeat() protected ​

php
protected function getRiderSeat() : \pocketmine\entity\riding\RideableSeat

The seat of the rider (vanilla rideable component).

getTemper() ​

php
public function getTemper() : int

getXpDropAmount() ​

php
public function getXpDropAmount() : int

hasArmorSlot() ​

php
public function hasArmorSlot() : bool

Whether the animal wears horse armor (horses and zombie horses).

inheritStats() protected ​

php
protected function inheritStats(\pocketmine\entity\animal\AbstractHorse $baby, \pocketmine\entity\animal\Animal $partner) : void

Gives a baby the average of the parents' stats plus a random part, like Java.

initEntity() protected ​

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

isBeingBrokenIn() ​

php
public function isBeingBrokenIn() : bool

Returns whether a player rides the untamed animal to tame it.

isBreedingItem() ​

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

isChested() ​

php
public function isChested() : bool

isDrivenByRiderClient() protected ​

php
protected function isDrivenByRiderClient() : bool

isHorseArmor() ​

php
public static function isHorseArmor(\pocketmine\item\Item $item) : bool

isSaddled() ​

php
public function isSaddled() : bool

isTameable() ​

php
public function isTameable() : bool

Whether the animal can be tamed at all (skeleton and zombie horses can't).

isTemptItem() protected ​

php
protected function isTemptItem(\pocketmine\item\Item $item) : bool

Items that lure the animal (horses: golden apples and carrots).

onDeath() protected ​

php
protected function onDeath() : void

onDispose() protected ​

php
protected function onDispose() : void

onInteractWithItem() protected ​

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

onInventorySlotChange() protected ​

php
protected function onInventorySlotChange(int $slot, \pocketmine\item\Item $before) : void

Called when a slot of the inventory changed (through the screen, an interaction or a plugin).

onRiderJump() protected ​

php
protected function onRiderJump(float $power) : void

Jumps with the given power (0.4 to 1) when the rider releases the jump button (server-moved horses only).

openInventory() ​

php
public function openInventory(\pocketmine\player\Player $player) : bool

Opens the inventory to the player. Returns whether it opened.

randomRange() protected ​

php
protected static function randomRange(float $min, float $max) : float

Random value between $min and $max.

randomStats() protected ​

php
abstract protected function randomStats() : array

Random stats of a new animal: [max health, movement speed, jump strength].

registerGoals() protected ​

php
protected function registerGoals() : void

resizeInventory() protected ​

php
protected function resizeInventory() : void

Replaces 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() ​

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

sendSpawnPacket() protected ​

php
protected function sendSpawnPacket(\pocketmine\player\Player $player) : void

setChested() ​

php
public function setChested(bool $chested) : void

Puts a chest on the animal or takes it off (the contents of the chest that no longer fit are dropped).

setHorseArmor() ​

php
public function setHorseArmor(\pocketmine\item\Item $armor) : void

setJumpStrength() ​

php
public function setJumpStrength(float $strength) : void

setSaddled() ​

php
public function setSaddled(bool $saddled) : void

Puts a saddle in the saddle slot, or empties it.

setTemper() ​

php
public function setTemper(int $temper) : void

steer() protected ​

php
protected function steer(\pocketmine\player\Player $rider, \pocketmine\entity\riding\RiderInput $input) : void

syncNetworkData() protected ​

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

tryMount() ​

php
public function tryMount(\pocketmine\player\Player $player) : bool

Makes the player ride the animal (breaking it in if it isn't tamed, see the class doc). Returns whether the player got on.

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