13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol;
20 public const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET;
22 public const TYPE_REPLACE_PAGE = 0;
23 public const TYPE_ADD_PAGE = 1;
24 public const TYPE_DELETE_PAGE = 2;
25 public const TYPE_SWAP_PAGES = 3;
26 public const TYPE_SIGN_BOOK = 4;
29 public int $inventorySlot;
30 public int $pageNumber;
31 public int $secondaryPageNumber;
33 public string $photoName;
35 public string $author;
39 $this->type = $in->getByte();
40 $this->inventorySlot = $in->
getByte();
43 case self::TYPE_REPLACE_PAGE:
44 case self::TYPE_ADD_PAGE:
45 $this->pageNumber = $in->
getByte();
49 case self::TYPE_DELETE_PAGE:
50 $this->pageNumber = $in->
getByte();
52 case self::TYPE_SWAP_PAGES:
53 $this->pageNumber = $in->
getByte();
54 $this->secondaryPageNumber = $in->
getByte();
56 case self::TYPE_SIGN_BOOK:
67 $out->putByte($this->type);
68 $out->putByte($this->inventorySlot);
71 case self::TYPE_REPLACE_PAGE:
72 case self::TYPE_ADD_PAGE:
73 $out->putByte($this->pageNumber);
74 $out->putString($this->text);
75 $out->putString($this->photoName);
77 case self::TYPE_DELETE_PAGE:
78 $out->putByte($this->pageNumber);
80 case self::TYPE_SWAP_PAGES:
81 $out->putByte($this->pageNumber);
82 $out->putByte($this->secondaryPageNumber);
84 case self::TYPE_SIGN_BOOK:
85 $out->putString($this->title);
86 $out->putString($this->author);
87 $out->putString($this->xuid);
90 throw new \InvalidArgumentException(
"Unknown book edit type $this->type!");
95 return $handler->handleBookEdit($this);
encodePayload(PacketSerializer $out)
decodePayload(PacketSerializer $in)
handle(PacketHandlerInterface $handler)