diff --git a/src/pocketmine/network/mcpe/protocol/LabTablePacket.php b/src/pocketmine/network/mcpe/protocol/LabTablePacket.php index f0c3e3920..8f45bcc56 100644 --- a/src/pocketmine/network/mcpe/protocol/LabTablePacket.php +++ b/src/pocketmine/network/mcpe/protocol/LabTablePacket.php @@ -30,12 +30,29 @@ use pocketmine\network\mcpe\NetworkSession; class LabTablePacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET; + /** @var int */ + public $uselessByte; //0 for client -> server, 1 for server -> client. Seems useless. + + /** @var int */ + public $x; + /** @var int */ + public $y; + /** @var int */ + public $z; + + /** @var int */ + public $reactionType; + protected function decodePayload(){ - //TODO + $this->uselessByte = $this->getByte(); + $this->getSignedBlockPosition($this->x, $this->y, $this->z); + $this->reactionType = $this->getByte(); } protected function encodePayload(){ - //TODO + $this->putByte($this->uselessByte); + $this->putSignedBlockPosition($this->x, $this->y, $this->z); + $this->putByte($this->reactionType); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php b/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php index bfb3c3cbf..6216c43ea 100644 --- a/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php +++ b/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php @@ -30,12 +30,15 @@ use pocketmine\network\mcpe\NetworkSession; class RemoveObjectivePacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET; + /** @var string */ + public $objectiveName; + protected function decodePayload(){ - //TODO + $this->objectiveName = $this->getString(); } protected function encodePayload(){ - //TODO + $this->putString($this->objectiveName); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php b/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php index 8592e3869..a4b1aa54a 100644 --- a/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php @@ -30,12 +30,31 @@ use pocketmine\network\mcpe\NetworkSession; class SetDisplayObjectivePacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::SET_DISPLAY_OBJECTIVE_PACKET; + /** @var string */ + public $displaySlot; + /** @var string */ + public $objectiveName; + /** @var string */ + public $displayName; + /** @var string */ + public $criteriaName; + /** @var int */ + public $sortOrder; + protected function decodePayload(){ - //TODO + $this->displaySlot = $this->getString(); + $this->objectiveName = $this->getString(); + $this->displayName = $this->getString(); + $this->criteriaName = $this->getString(); + $this->sortOrder = $this->getVarInt(); } protected function encodePayload(){ - //TODO + $this->putString($this->displaySlot); + $this->putString($this->objectiveName); + $this->putString($this->displayName); + $this->putString($this->criteriaName); + $this->putVarInt($this->sortOrder); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SetScorePacket.php b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php index 186cc44ac..f1efb6579 100644 --- a/src/pocketmine/network/mcpe/protocol/SetScorePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php @@ -26,16 +26,37 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\ScorePacketEntry; class SetScorePacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::SET_SCORE_PACKET; + public const TYPE_MODIFY_SCORE = 0; + public const TYPE_RESET_SCORE = 1; + + /** @var int */ + public $type; + /** @var ScorePacketEntry[] */ + public $entries = []; + protected function decodePayload(){ - //TODO + $this->type = $this->getByte(); + for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){ + $entry = new ScorePacketEntry(); + $entry->uuid = $this->getUUID(); + $entry->objectiveName = $this->getString(); + $entry->score = $this->getLInt(); + } } protected function encodePayload(){ - //TODO + $this->putByte($this->type); + $this->putUnsignedVarInt(count($this->entries)); + foreach($this->entries as $entry){ + $this->putUUID($entry->uuid); + $this->putString($entry->objectiveName); + $this->putLInt($entry->score); + } } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php new file mode 100644 index 000000000..a2c0326d1 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php @@ -0,0 +1,35 @@ +