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()); }
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()); }
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()); }
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; }