Skip to content

AgeLockTrait 5.47.0 ​

trait · pocketmine\entity\AgeLockTrait · source

Golden dandelion age lock of baby mobs (Bedrock minecraft:ageable pause_growth_items / reset_growth_items, Java AgeableMob): using a golden dandelion on a baby stops it from growing up (and makes it persistent), using another one lets it grow again. Both restart its growth from the beginning. A locked baby doesn't grow and feeding doesn't age it. After each use the dandelion can't be used on it for 2 seconds, while particles show above it.

For Mob subclasses: the using class restarts the growth in AgeLockTrait::restartGrowth() and stops growing while AgeLockTrait::isAgeLocked().

Constants ​

AGE_LOCK_COOLDOWN_TICKS ​

php
public const AGE_LOCK_COOLDOWN_TICKS = 40

TAG_AGE_LOCKED ​

php
public const TAG_AGE_LOCKED = "AgeLocked"

Methods ​

canBeAgeLocked() protected ​

php
protected function canBeAgeLocked() : bool

Returns whether a golden dandelion can lock the age of this mob (Bedrock: the golden dandelion is in its pause_growth_items).

getAgeLockCooldown() ​

php
public function getAgeLockCooldown() : int

Returns the ticks left before the golden dandelion can be used on this baby again.

isAgeLocked() ​

php
public function isAgeLocked() : bool

Returns whether a golden dandelion stopped this baby from growing up.

isGoldenDandelion() ​

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

loadAgeLock() protected ​

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

restartGrowth() protected ​

php
abstract protected function restartGrowth() : void

Makes the baby start growing up again from the beginning.

saveAgeLock() protected ​

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

setAgeLocked() ​

php
public function setAgeLocked(bool $locked) : void

tickAgeLock() protected ​

php
protected function tickAgeLock(int $tickDiff) : void

Shows the lock/unlock particles (one every other tick, as Java) and runs the cooldown down. Only called while AgeLockTrait::getAgeLockCooldown() is above 0.

tryUseGoldenDandelion() protected ​

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

Locks or unlocks the age of this baby if the player uses a golden dandelion on it. Returns whether it did.

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.