Avoid bogus assumptions about block and item NBT on tiles

This commit is contained in:
Dylan K. Taylor
2022-07-17 21:23:41 +01:00
parent 4f2f9b4352
commit 012b668537
6 changed files with 31 additions and 4 deletions

View File

@ -26,6 +26,7 @@ namespace pocketmine\block\tile;
use pocketmine\item\Item;
use pocketmine\item\WritableBookBase;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\convert\ItemTranslator;
use function count;
/**
@ -80,7 +81,7 @@ class Lectern extends Spawnable{
$nbt->setByte(self::TAG_HAS_BOOK, $this->book !== null ? 1 : 0);
$nbt->setInt(self::TAG_PAGE, $this->viewedPage);
if($this->book !== null){
$nbt->setTag(self::TAG_BOOK, $this->book->nbtSerialize());
$nbt->setTag(self::TAG_BOOK, ItemTranslator::getInstance()->toNetworkNbt($this->book));
$nbt->setInt(self::TAG_TOTAL_PAGES, count($this->book->getPages()));
}
}