namedtag["Profession"] ?? self::PROFESSION_FARMER; if($profession > 4 or $profession < 0){ $profession = self::PROFESSION_FARMER; } $this->setProfession($profession); } public function saveNBT(){ parent::saveNBT(); $this->namedtag->Profession = new IntTag("Profession", $this->getProfession()); } public function spawnTo(Player $player){ $pk = new AddEntityPacket(); $pk->entityRuntimeId = $this->getId(); $pk->type = Villager::NETWORK_ID; $pk->position = $this->asVector3(); $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); parent::spawnTo($player); } /** * Sets the villager profession * * @param int $profession */ public function setProfession(int $profession){ $this->setDataProperty(self::DATA_VARIANT, self::DATA_TYPE_INT, $profession); } public function getProfession() : int{ return $this->getDataProperty(self::DATA_VARIANT); } public function isBaby() : bool{ return $this->getGenericFlag(self::DATA_FLAG_BABY); } }