33 public const PROFESSION_FARMER = 0;
34 public const PROFESSION_LIBRARIAN = 1;
35 public const PROFESSION_PRIEST = 2;
36 public const PROFESSION_BLACKSMITH = 3;
37 public const PROFESSION_BUTCHER = 4;
39 private const TAG_PROFESSION =
"Profession";
41 public static function getNetworkTypeId() :
string{
return EntityIds::VILLAGER; }
43 private bool $baby =
false;
44 private int $profession = self::PROFESSION_FARMER;
50 public function getName() :
string{
54 protected function initEntity(
CompoundTag $nbt) :
void{
55 parent::initEntity($nbt);
58 $profession = $nbt->getInt(self::TAG_PROFESSION, self::PROFESSION_FARMER);
60 if($profession > 4 || $profession < 0){
61 $profession = self::PROFESSION_FARMER;
68 $nbt = parent::saveNBT();
69 $nbt->
setInt(self::TAG_PROFESSION, $this->getProfession());
78 $this->profession = $profession;
79 $this->networkPropertiesDirty =
true;
82 public function getProfession() : int{
83 return $this->profession;
86 public function isBaby() : bool{
90 protected function syncNetworkData(EntityMetadataCollection $properties) : void{
91 parent::syncNetworkData($properties);
92 $properties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby);
94 $properties->setInt(EntityMetadataProperties::VARIANT, $this->profession);