35 public const PROFESSION_FARMER = 0;
36 public const PROFESSION_LIBRARIAN = 1;
37 public const PROFESSION_PRIEST = 2;
38 public const PROFESSION_BLACKSMITH = 3;
39 public const PROFESSION_BUTCHER = 4;
41 private const TAG_PROFESSION =
"Profession";
43 public function getNetworkTypeId() :
string{
return EntityIds::VILLAGER; }
45 private bool $baby =
false;
46 private int $profession = self::PROFESSION_FARMER;
52 public function getName() :
string{
56 protected function initEntity(
CompoundTag $nbt) :
void{
57 parent::initEntity($nbt);
60 $profession = $nbt->getInt(self::TAG_PROFESSION, self::PROFESSION_FARMER);
62 if($profession > 4 || $profession < 0){
63 $profession = self::PROFESSION_FARMER;
70 $nbt = parent::saveNBT();
71 $nbt->
setInt(self::TAG_PROFESSION, $this->getProfession());
80 $this->profession = $profession;
81 $this->networkPropertiesDirty =
true;
84 public function getProfession() : int{
85 return $this->profession;
88 public function isBaby() : bool{
97 parent::syncNetworkData($properties);
98 $properties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby);
100 $properties->setInt(EntityMetadataProperties::VARIANT, $this->profession);