getTag("Rotation"); if(!($yawPitch instanceof ListTag) or $yawPitch->getTagType() !== NBT::TAG_Float){ throw new \UnexpectedValueException("'Rotation' should be a List"); } /** @var FloatTag[] $values */ $values = $yawPitch->getValue(); if(count($values) !== 2){ throw new \UnexpectedValueException("Expected exactly 2 entries for 'Rotation'"); } return Location::fromObject($pos, $world, $values[0]->getValue(), $values[1]->getValue()); } public static function parseVec3(CompoundTag $nbt, string $tagName, bool $optional) : Vector3{ $pos = $nbt->getTag($tagName); if($pos === null and $optional){ return new Vector3(0, 0, 0); } if(!($pos instanceof ListTag) or $pos->getTagType() !== NBT::TAG_Double){ throw new \UnexpectedValueException("'$tagName' should be a List"); } /** @var DoubleTag[] $values */ $values = $pos->getValue(); if(count($values) !== 3){ throw new \UnexpectedValueException("Expected exactly 3 entries in '$tagName' tag"); } return new Vector3($values[0]->getValue(), $values[1]->getValue(), $values[2]->getValue()); } }