From a5c6c8b9731e799a4e12a6a4a918c1d0093a645e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 12 Jul 2017 19:30:26 +0100 Subject: [PATCH] Added some fields to new packets gave up on EventPacket because it's a mess, and StructureBlockUpdate is a job all by itself --- .../mcpe/protocol/AddBehaviorTreePacket.php | 7 +++-- .../network/mcpe/protocol/CameraPacket.php | 11 ++++++-- .../network/mcpe/protocol/EventPacket.php | 27 +++++++++++++++++-- .../mcpe/protocol/PurchaseReceiptPacket.php | 13 +++++++-- .../mcpe/protocol/ShowStoreOfferPacket.php | 6 +++-- .../mcpe/protocol/SimpleEventPacket.php | 6 +++-- .../mcpe/protocol/UpdateEquipPacket.php | 18 +++++++++++-- 7 files changed, 74 insertions(+), 14 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/AddBehaviorTreePacket.php b/src/pocketmine/network/mcpe/protocol/AddBehaviorTreePacket.php index af461e714..56a5e0fc5 100644 --- a/src/pocketmine/network/mcpe/protocol/AddBehaviorTreePacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddBehaviorTreePacket.php @@ -30,12 +30,15 @@ use pocketmine\network\mcpe\NetworkSession; class AddBehaviorTreePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET; + /** @var string */ + public $unknownString1; + public function decodePayload(){ - //TODO + $this->unknownString1 = $this->getString(); } public function encodePayload(){ - //TODO + $this->putString($this->unknownString1); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/CameraPacket.php b/src/pocketmine/network/mcpe/protocol/CameraPacket.php index 2f697bb39..ecc62f862 100644 --- a/src/pocketmine/network/mcpe/protocol/CameraPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CameraPacket.php @@ -30,12 +30,19 @@ use pocketmine\network\mcpe\NetworkSession; class CameraPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CAMERA_PACKET; + /** @var int */ + public $cameraUniqueId; + /** @var int */ + public $playerUniqueId; + public function decodePayload(){ - //TODO + $this->cameraUniqueId = $this->getEntityUniqueId(); + $this->playerUniqueId = $this->getEntityUniqueId(); } public function encodePayload(){ - //TODO + $this->putEntityUniqueId($this->cameraUniqueId); + $this->putEntityUniqueId($this->playerUniqueId); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/EventPacket.php b/src/pocketmine/network/mcpe/protocol/EventPacket.php index 984c45680..f76b89e9a 100644 --- a/src/pocketmine/network/mcpe/protocol/EventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EventPacket.php @@ -30,12 +30,35 @@ use pocketmine\network\mcpe\NetworkSession; class EventPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::EVENT_PACKET; + const TYPE_ACHIEVEMENT_AWARDED = 0; + const TYPE_ENTITY_INTERACT = 1; + const TYPE_PORTAL_BUILT = 2; + const TYPE_PORTAL_USED = 3; + const TYPE_MOB_KILLED = 4; + const TYPE_CAULDRON_USED = 5; + const TYPE_PLAYER_DEATH = 6; + const TYPE_BOSS_KILLED = 7; + const TYPE_AGENT_COMMAND = 8; + const TYPE_AGENT_CREATED = 9; + + public $playerRuntimeId; + public $eventData; + public $type; + public function decodePayload(){ - //TODO + $this->playerRuntimeId = $this->getEntityRuntimeId(); + $this->eventData = $this->getVarInt(); + $this->type = $this->getByte(); + + //TODO: nice confusing mess } public function encodePayload(){ - //TODO + $this->putEntityRuntimeId($this->playerRuntimeId); + $this->putVarInt($this->eventData); + $this->putByte($this->type); + + //TODO: also nice confusing mess } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/PurchaseReceiptPacket.php b/src/pocketmine/network/mcpe/protocol/PurchaseReceiptPacket.php index 7da5afa0e..d1926475b 100644 --- a/src/pocketmine/network/mcpe/protocol/PurchaseReceiptPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PurchaseReceiptPacket.php @@ -30,12 +30,21 @@ use pocketmine\network\mcpe\NetworkSession; class PurchaseReceiptPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::PURCHASE_RECEIPT_PACKET; + /** @var string[] */ + public $entries = []; + public function decodePayload(){ - //TODO + $count = $this->getUnsignedVarInt(); + for($i = 0; $i < $count; ++$i){ + $this->entries[] = $this->getString(); + } } public function encodePayload(){ - //TODO + $this->putUnsignedVarInt(count($this->entries)); + foreach($this->entries as $entry){ + $this->putString($entry); + } } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php b/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php index b44e1d352..ab079ce30 100644 --- a/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php @@ -30,12 +30,14 @@ use pocketmine\network\mcpe\NetworkSession; class ShowStoreOfferPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET; + public $offerId; + public function decodePayload(){ - //TODO + $this->offerId = $this->getString(); } public function encodePayload(){ - //TODO + $this->putString($this->offerId); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php b/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php index 4337a8a1e..354008f2a 100644 --- a/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php @@ -30,12 +30,14 @@ use pocketmine\network\mcpe\NetworkSession; class SimpleEventPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET; + public $unknownShort1; + public function decodePayload(){ - //TODO + $this->unknownShort1 = $this->getLShort(); } public function encodePayload(){ - //TODO + $this->putLShort($this->unknownShort1); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php index 16b8239b6..7f3c9bbd7 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php @@ -30,12 +30,26 @@ use pocketmine\network\mcpe\NetworkSession; class UpdateEquipPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET; + public $windowId; + public $windowType; + public $unknownVarint; //TODO: find out what this is (vanilla always sends 0) + public $entityUniqueId; + public $namedtag; + public function decodePayload(){ - //TODO + $this->windowId = $this->getByte(); + $this->windowType = $this->getByte(); + $this->unknownVarint = $this->getVarInt(); + $this->entityUniqueId = $this->getEntityUniqueId(); + $this->namedtag = $this->get(true); } public function encodePayload(){ - //TODO + $this->putByte($this->windowId); + $this->putByte($this->windowType); + $this->putVarInt($this->unknownVarint); + $this->putEntityUniqueId($this->entityUniqueId); + $this->put($this->namedtag); } public function handle(NetworkSession $session) : bool{