37    public const TAG_HAS_BOOK = 
"hasBook";
 
   38    public const TAG_PAGE = 
"page";
 
   39    public const TAG_TOTAL_PAGES = 
"totalPages";
 
   40    public const TAG_BOOK = 
"book";
 
   42    private int $viewedPage = 0;
 
   45    public function readSaveData(
CompoundTag $nbt) : 
void{
 
   46        $this->viewedPage = $nbt->getInt(self::TAG_PAGE, 0);
 
   48            $book = Item::safeNbtDeserialize($itemTag, 
"Lectern ($this->position) book");
 
   56        $nbt->setByte(self::TAG_HAS_BOOK, $this->book !== null ? 1 : 0);
 
   57        $nbt->
setInt(self::TAG_PAGE, $this->viewedPage);
 
   58        if($this->book !== 
null){
 
   59            $nbt->
setTag(self::TAG_BOOK, $this->book->nbtSerialize());
 
   60            $nbt->
setInt(self::TAG_TOTAL_PAGES, count($this->book->getPages()));
 
 
   64    public function getViewedPage() : int{
 
   65        return $this->viewedPage;
 
   68    public function setViewedPage(
int $viewedPage) : void{
 
   69        $this->viewedPage = $viewedPage;
 
   72    public function getBook() : ?WritableBookBase{
 
   73        return $this->book !== null ? clone $this->book : null;
 
   76    public function setBook(?WritableBookBase $book) : void{
 
   77        $this->book = $book !== null && !$book->isNull() ? clone $book : null;
 
   81        $nbt->setByte(self::TAG_HAS_BOOK, $this->book !== null ? 1 : 0);
 
   82        $nbt->
setInt(self::TAG_PAGE, $this->viewedPage);
 
   83        if($this->book !== 
null){
 
   84            $nbt->
setTag(self::TAG_BOOK, TypeConverter::getInstance()->getItemTranslator()->toNetworkNbt($this->book));
 
   85            $nbt->
setInt(self::TAG_TOTAL_PAGES, count($this->book->getPages()));