Adding writable and written books. (#1397)

* Adding writable and written books.
* Added a PlayerEditBookEvent.
* Changed BookEditPacket field names.
This commit is contained in:
Sandertv
2017-10-08 12:49:57 +02:00
committed by Dylan K. Taylor
parent f6875705a1
commit 81dee2f9fc
7 changed files with 525 additions and 8 deletions

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
use pocketmine\network\mcpe\protocol\AnimatePacket;
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
use pocketmine\network\mcpe\protocol\BookEditPacket;
use pocketmine\network\mcpe\protocol\BossEventPacket;
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
@ -231,6 +232,10 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
return $this->player->changeSkin($packet->skin, $packet->newSkinName, $packet->oldSkinName);
}
public function handleBookEdit(BookEditPacket $packet) : bool{
return $this->player->handleBookEdit($packet);
}
public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{
return false; //TODO: GUI stuff
}

View File

@ -46,9 +46,9 @@ class BookEditPacket extends DataPacket{
public $secondaryPageNumber;
/** @var string */
public $content1;
public $text;
/** @var string */
public $content2;
public $photoName;
/** @var string */
public $title;
@ -63,8 +63,8 @@ class BookEditPacket extends DataPacket{
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$this->pageNumber = $this->getByte();
$this->content1 = $this->getString();
$this->content2 = $this->getString();
$this->text = $this->getString();
$this->photoName = $this->getString();
break;
case self::TYPE_DELETE_PAGE:
$this->pageNumber = $this->getByte();
@ -90,8 +90,8 @@ class BookEditPacket extends DataPacket{
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$this->putByte($this->pageNumber);
$this->putString($this->content1);
$this->putString($this->content2);
$this->putString($this->text);
$this->putString($this->photoName);
break;
case self::TYPE_DELETE_PAGE:
$this->putByte($this->pageNumber);