34    public const GENERATION_ORIGINAL = 0;
 
   35    public const GENERATION_COPY = 1;
 
   36    public const GENERATION_COPY_OF_COPY = 2;
 
   37    public const GENERATION_TATTERED = 3;
 
   39    public const TAG_GENERATION = 
"generation"; 
 
   40    public const TAG_AUTHOR = 
"author"; 
 
   41    public const TAG_TITLE = 
"title"; 
 
   43    private int $generation = self::GENERATION_ORIGINAL;
 
   44    private string $author = 
"";
 
   45    private string $title = 
"";
 
   56        return $this->generation;
 
 
   65        if($generation < 0 || $generation > 3){
 
   66            throw new \InvalidArgumentException(
"Generation \"$generation\" is out of range");
 
   69        $this->generation = $generation;
 
 
   87    public function setAuthor(
string $authorName) : self{
 
   88        if(strlen($authorName) > 
Limits::INT16_MAX){
 
   89            throw new \InvalidArgumentException(sprintf(
"Author must be at most %d bytes, but have %d bytes", Limits::INT16_MAX, strlen($authorName)));
 
   91        Utils::checkUTF8($authorName);
 
   92        $this->author = $authorName;
 
 
  109        if(strlen($title) > 
Limits::INT16_MAX){
 
  110            throw new \InvalidArgumentException(sprintf(
"Title must be at most %d bytes, but have %d bytes", Limits::INT16_MAX, strlen($title)));
 
  112        Utils::checkUTF8($title);
 
  113        $this->title = $title;
 
 
  118        parent::deserializeCompoundTag($tag);
 
  119        $this->generation = $tag->getInt(self::TAG_GENERATION, $this->generation);
 
  120        $this->author = $tag->getString(self::TAG_AUTHOR, $this->author);
 
  121        $this->title = $tag->getString(self::TAG_TITLE, $this->title);
 
 
  124    protected function serializeCompoundTag(
CompoundTag $tag) : void{
 
  125        parent::serializeCompoundTag($tag);
 
  126        $tag->
setInt(self::TAG_GENERATION, $this->generation);
 
  127        $tag->
setString(self::TAG_AUTHOR, $this->author);
 
  128        $tag->
setString(self::TAG_TITLE, $this->title);