Skip to content

CamelTrait 5.46.0 ​

trait · pocketmine\entity\animal\CamelTrait · source

What camels and camel husks share (camel.json, camel_husk.json): 1.7x2.375 (0.945 tall when sitting), sitting down from time to time (SITTING flag), two seats (1.905 up, 0.5 forwards and backwards), a saddle (no taming needed) that lets the front rider steer (WASD_CONTROLLED; clients predict it like horses, otherwise the server moves it at the movement attribute x 2.1 blocks per tick, +0.1 movement when sprinting) and dash by releasing the jump button (CAN_DASH, vanilla dash_action: 2.75 s cooldown shown with HAS_DASH_COOLDOWN, momentum 20 x movement forwards and 0.6 up, scaled by how long jump was held).

The using class calls CamelTrait::loadCamel(), CamelTrait::saveCamel(), CamelTrait::handleDashInput() from handleRiderInput(), CamelTrait::tickDashCooldown() from entityBaseTick() and CamelTrait::syncCamelData() from syncNetworkData().

Constants ​

TAG_SADDLED ​

php
public const TAG_SADDLED = "Saddled"

Methods ​

canBeSteeredBy() ​

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

createSitGoal() protected ​

php
protected function createSitGoal(int $chance) : \pocketmine\entity\ai\goal\Goal

The goal sitting the camel down from time to time while nobody rides it, for 10 to 30 seconds (vanilla random_sitting / random_look_around_and_sit), 1 in $chance per tick.

dash() ​

php
public function dash(float $power) : void

Dashes forwards with the given power (0.4 to 1) and starts the cooldown. A client predicting the camel moves it itself; the server only does it when it moves the camel.

getCamelSeats() protected ​

php
protected function getCamelSeats() : array

getRiddenSpeed() protected ​

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

handleDashInput() protected ​

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

Holding jump charges a dash, releasing it dashes (Java formula for the power).

hasDashCooldown() ​

php
public function hasDashCooldown() : bool

isDrivenByRiderClient() protected ​

php
protected function isDrivenByRiderClient() : bool

isSaddled() ​

php
public function isSaddled() : bool

isSitting() ​

php
public function isSitting() : bool

loadCamel() protected ​

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

saveCamel() protected ​

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

setSaddled() ​

php
public function setSaddled(bool $saddled) : void

setSitting() ​

php
public function setSitting(bool $sitting) : void

shearSaddle() protected ​

php
protected function shearSaddle() : bool

Shears take the saddle off when nobody rides (vanilla removesaddle interaction): it drops above the camel, a bit lower when sitting. Returns whether it came off.

syncCamelData() protected ​

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

tickDashCooldown() protected ​

php
protected function tickDashCooldown(int $tickDiff) : void

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