本文整理汇总了PHP中pocketmine\entity\Animal::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Animal::__construct方法的具体用法?PHP Animal::__construct怎么用?PHP Animal::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\entity\Animal
的用法示例。
在下文中一共展示了Animal::__construct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(FullChunk $chunk, CompoundTag $nbt)
{
if (!isset($nbt->RabbitType)) {
$nbt->RabbitType = new ByteTag("RabbitType", $this->getRandomRabbitType());
}
parent::__construct($chunk, $nbt);
$this->setDataProperty(self::DATA_RABBIT_TYPE, self::DATA_TYPE_BYTE, $this->getRabbitType());
}
示例2: __construct
public function __construct(FullChunk $chunk, CompoundTag $nbt)
{
if (!isset($nbt->CatType)) {
$nbt->CatType = new ByteTag("CatType", mt_rand(0, 3));
}
parent::__construct($chunk, $nbt);
$this->setDataProperty(self::DATA_CAT_TYPE, self::DATA_TYPE_BYTE, $this->getCatType());
}
示例3: __construct
public function __construct(FullChunk $chunk, CompoundTag $nbt)
{
if (!isset($nbt->Color)) {
$nbt->Color = new ByteTag("Color", self::getRandomColor());
}
parent::__construct($chunk, $nbt);
$this->setDataProperty(self::DATA_COLOR_INFO, self::DATA_TYPE_BYTE, $this->getColor());
}
示例4: __construct
public function __construct(FullChunk $chunk, CompoundTag $nbt, PetOwner $petOwner)
{
// if $petOwner is null pocketmine is probably trying to reload a saved
// version of this entity which we do not want anymore - as it is not cancellable ( I think ? )
// just let it create and the update function will despawn the entity immediatley when it finds
// it to have no targetPlayer
if (is_null($petOwner)) {
parent::__construct($chunk, $nbt);
$this->close();
return;
}
// TODO Catch error
$this->petOwner = $petOwner;
$this->petName_unformatted = $petOwner->petProperties->petName;
$this->ownerName = $this->petOwner->player->getName();
$this->petName = Main::translateColors("&", "&c[" . $this->ownerName . "] &f" . $this->petName_unformatted);
$this->petType = $petOwner->petType;
$location = $this->petOwner->player->getLocation();
$nbt = new CompoundTag("", [new ListTag("Pos", [new DoubleTag("", $location->x), new DoubleTag("", $location->y), new DoubleTag("", $location->z)]), new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), new ListTag("Rotation", [new FloatTag("", $location->yaw), new FloatTag("", $location->pitch)])]);
$nbt->CustomName = new StringTag("CustomName", $this->petName);
$nbt->CustomNameVisible = new ByteTag("CustomNameVisible", 1);
$chunk = $location->getLevel()->getChunk($location->x >> 4, $location->z >> 4);
$this->setNameTagVisible(true);
parent::__construct($chunk, $nbt);
$this->setNameTagVisible(true);
$this->dataProperties = array_replace($this->dataProperties, $this->petType->meta);
$this->spawnToAll();
return true;
}