40 private const TAG_SKULL_TYPE =
"SkullType";
41 private const TAG_ROTATION =
"Rotation";
42 private const TAG_ROT =
"Rot";
43 private const TAG_MOUTH_MOVING =
"MouthMoving";
44 private const TAG_MOUTH_TICK_COUNT =
"MouthTickCount";
46 private MobHeadType $mobHeadType = MobHeadType::SKELETON;
47 private int $rotation = 0;
49 public function readSaveData(
CompoundTag $nbt) :
void{
50 if(($skullTypeTag = $nbt->
getTag(self::TAG_SKULL_TYPE)) instanceof
ByteTag){
51 $mobHeadType = MobHeadTypeIdMap::getInstance()->fromId($skullTypeTag->getValue());
52 if($mobHeadType ===
null){
55 $this->mobHeadType = $mobHeadType;
59 $yaw = $nbt->getFloat(self::TAG_ROTATION, 0.0);
60 $this->rotation = ((int) floor(($yaw * 16 / 360) + 0.5)) & 0xf;
62 $rotation = $nbt->getByte(self::TAG_ROT, 0);
63 if($rotation >= 0 && $rotation <= 15){
64 $this->rotation = $rotation;
70 $nbt->setByte(self::TAG_SKULL_TYPE,
MobHeadTypeIdMap::getInstance()->toId($this->mobHeadType));
71 $nbt->
setFloat(self::TAG_ROTATION, $this->rotation * 360.0 / 16.0);
74 public function setMobHeadType(MobHeadType $type) : void{
75 $this->mobHeadType = $type;
78 public function getMobHeadType() : MobHeadType{
79 return $this->mobHeadType;
82 public function getRotation() : int{
83 return $this->rotation;
86 public function setRotation(
int $rotation) : void{
87 $this->rotation = $rotation;
91 $nbt->setByte(self::TAG_SKULL_TYPE,
MobHeadTypeIdMap::getInstance()->toId($this->mobHeadType));
92 $nbt->
setFloat(self::TAG_ROTATION, $this->rotation * 360.0 / 16.0);