CamelTrait 5.46.0
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
public const TAG_SADDLED = "Saddled"Methods
canBeSteeredBy()
public function canBeSteeredBy(\pocketmine\player\Player $rider) : boolcreateSitGoal() protected
protected function createSitGoal(int $chance) : \pocketmine\entity\ai\goal\GoalThe 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()
public function dash(float $power) : voidDashes 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
protected function getCamelSeats() : arraygetRiddenSpeed() protected
protected function getRiddenSpeed(\pocketmine\player\Player $rider) : floathandleDashInput() protected
protected function handleDashInput(\pocketmine\player\Player $rider, \pocketmine\entity\riding\RiderInput $input) : voidHolding jump charges a dash, releasing it dashes (Java formula for the power).
hasDashCooldown()
public function hasDashCooldown() : boolisDrivenByRiderClient() protected
protected function isDrivenByRiderClient() : boolisSaddled()
public function isSaddled() : boolisSitting()
public function isSitting() : boolloadCamel() protected
protected function loadCamel(\pocketmine\nbt\tag\CompoundTag $nbt) : voidsaveCamel() protected
protected function saveCamel(\pocketmine\nbt\tag\CompoundTag $nbt) : voidsetSaddled()
public function setSaddled(bool $saddled) : voidsetSitting()
public function setSitting(bool $sitting) : voidshearSaddle() protected
protected function shearSaddle() : boolShears 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
protected function syncCamelData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : voidtickDashCooldown() protected
protected function tickDashCooldown(int $tickDiff) : void