From f4369e31354160348b9768daf5ee67753cdf3444 Mon Sep 17 00:00:00 2001 From: dextudio Date: Wed, 18 Mar 2020 17:40:21 +0600 Subject: [PATCH 1/2] updates protocol 400 --- src/pocketmine/network/Network.php | 2 ++ .../protocol/AvailableCommandsPacket.php | 1 + .../network/protocol/DataPacket.php | 1 + src/pocketmine/network/protocol/Info.php | 4 +++- src/pocketmine/network/protocol/PEPacket.php | 2 ++ .../network/protocol/StartGamePacket.php | 20 +++++++++++++++---- src/pocketmine/utils/MetadataConvertor.php | 2 ++ 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index d8c595ec7..ec28e442f 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -272,6 +272,7 @@ public function getPacket($id, $playerProtocol){ case Info::PROTOCOL_389: case Info::PROTOCOL_392: case Info::PROTOCOL_393: + case Info::PROTOCOL_400: $class = $this->packetPool331[$id]; break; case Info::PROTOCOL_310: @@ -291,6 +292,7 @@ public function getPacket($id, $playerProtocol){ public static function getChunkPacketProtocol($playerProtocol){ switch ($playerProtocol) { + case Info::PROTOCOL_400: case Info::PROTOCOL_393: case Info::PROTOCOL_392: case Info::PROTOCOL_389: diff --git a/src/pocketmine/network/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/protocol/AvailableCommandsPacket.php index 61dfa4b73..42c91cf8d 100644 --- a/src/pocketmine/network/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/protocol/AvailableCommandsPacket.php @@ -86,6 +86,7 @@ public static function prepareCommands($commands) { Info::PROTOCOL_389 => new BinaryStream(), Info::PROTOCOL_392 => new BinaryStream(), Info::PROTOCOL_393 => new BinaryStream(), + Info::PROTOCOL_400 => new BinaryStream(), ]; foreach ($commands as $commandName => &$commandData) { // Replace &$commandData with $commandData when alises fix for 1.2 won't be needed anymore diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index 512030261..a65729ed9 100755 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -117,6 +117,7 @@ public static function initPackets() { self::$packetsIds[Info::PROTOCOL_389] = $oClass->getConstants(); self::$packetsIds[Info::PROTOCOL_392] = $oClass->getConstants(); self::$packetsIds[Info::PROTOCOL_393] = $oClass->getConstants(); + self::$packetsIds[Info::PROTOCOL_400] = $oClass->getConstants(); } } \ No newline at end of file diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 500de9f6c..af18b4523 100755 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -28,7 +28,7 @@ interface Info{ const CURRENT_PROTOCOL = 120; - const ACCEPTED_PROTOCOLS = [134, 135, 136, 137, 140, 141, 150, 160, 200, 201, 220, 221, 222, 224, 223, 240, 250, 260, 261, 270, 271, 273, 274, 280, 281, 282, 290, 291, 310, 311, 312, 313, 330, 331, 332, 342, 340, 350, 351, 352, 353, 354, 360, 361, 370, 371, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396]; + const ACCEPTED_PROTOCOLS = [134, 135, 136, 137, 140, 141, 150, 160, 200, 201, 220, 221, 222, 224, 223, 240, 250, 260, 261, 270, 271, 273, 274, 280, 281, 282, 290, 291, 310, 311, 312, 313, 330, 331, 332, 342, 340, 350, 351, 352, 353, 354, 360, 361, 370, 371, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396, 400]; const PROTOCOL_134 = 134; // 1.2.0.20, 1.2.0.22 const PROTOCOL_135 = 135; // 1.2.0.24, 1.2.0.25 @@ -87,6 +87,8 @@ interface Info{ const PROTOCOL_394 = 394; // 1.15.0.54 const PROTOCOL_395 = 395; // 1.15.0.55 const PROTOCOL_396 = 396; // 1.15.0.56 + const PROTOCOL_400 = 400; // 1.16.0.51 + /** OUTDATED (supporting will be removed with next release, may didn't work properly)*/ const PROTOCOL_120 = 120; // 1.2.0.xx (beta) diff --git a/src/pocketmine/network/protocol/PEPacket.php b/src/pocketmine/network/protocol/PEPacket.php index b183acd23..173728899 100644 --- a/src/pocketmine/network/protocol/PEPacket.php +++ b/src/pocketmine/network/protocol/PEPacket.php @@ -59,6 +59,8 @@ public function reset($playerProtocol = 0) { public final static function convertProtocol($protocol) { switch ($protocol) { + case Info::PROTOCOL_400: + return Info::PROTOCOL_400; case Info::PROTOCOL_396: case Info::PROTOCOL_395: case Info::PROTOCOL_394: diff --git a/src/pocketmine/network/protocol/StartGamePacket.php b/src/pocketmine/network/protocol/StartGamePacket.php index 198cda3e1..10db626da 100755 --- a/src/pocketmine/network/protocol/StartGamePacket.php +++ b/src/pocketmine/network/protocol/StartGamePacket.php @@ -70,7 +70,11 @@ public function encode($playerProtocol){ // Level settings $this->putSignedVarInt($this->seed); - + + if ($playerProtocol >= Info::PROTOCOL_400) { + $this->putByte(0);$this->putByte(0); $this->putString(0); + } + $this->putSignedVarInt($this->dimension); $this->putSignedVarInt($this->generator); @@ -87,6 +91,10 @@ public function encode($playerProtocol){ $this->putByte(1); // hasAchievementsDisabled $this->putSignedVarInt(0); // DayCycleStopTyme 1x VarInt + + if ($playerProtocol >= Info::PROTOCOL_400) { + $this->putByte(0); + } $this->putByte(0); //edu mode @@ -99,7 +107,7 @@ public function encode($playerProtocol){ $this->putLFloat(0); //lightning level if ($playerProtocol >= Info::PROTOCOL_332) { - $this->putByte(0); // ??? + $this->putByte(0); // has confirmed platform Locked Content } $this->putByte(1); // is multiplayer game @@ -111,8 +119,8 @@ public function encode($playerProtocol){ $this->putByte(1); // Broadcast to XBL? } - if ($playerProtocol >= Info::PROTOCOL_392) { - $this->putByte(0); // unknown + if ($playerProtocol >= Info::PROTOCOL_392 && $playerProtocol < Info::PROTOCOL_400) { + $this->putByte(0); // unknown } $this->putByte(1); // commands enabled @@ -177,6 +185,10 @@ public function encode($playerProtocol){ if ($playerProtocol >= Info::PROTOCOL_392) { $this->putLInt(16); //unknown $this->putLInt(16); //unknown + if ($playerProtocol >= Info::PROTOCOL_400) { + $this->putByte(0); + } + } // level settings end diff --git a/src/pocketmine/utils/MetadataConvertor.php b/src/pocketmine/utils/MetadataConvertor.php index f589eed1b..70fdb874e 100644 --- a/src/pocketmine/utils/MetadataConvertor.php +++ b/src/pocketmine/utils/MetadataConvertor.php @@ -217,6 +217,7 @@ public static function updateMeta($meta, $protocol) { private static function updateMetaIds($meta, $protocol) { switch ($protocol) { + case Info::PROTOCOL_400: case Info::PROTOCOL_393: case Info::PROTOCOL_392: case Info::PROTOCOL_389: @@ -278,6 +279,7 @@ private static function updateEntityFlags($meta, $protocol) { return $meta; } switch ($protocol) { + case Info::PROTOCOL_400: case Info::PROTOCOL_393: case Info::PROTOCOL_392: case Info::PROTOCOL_389: From 03cbc0ddef33d343c5f3c14cdb1b963523d27fb2 Mon Sep 17 00:00:00 2001 From: dextudio Date: Thu, 19 Mar 2020 14:32:01 +0600 Subject: [PATCH 2/2] fix explode problem --- .../network/protocol/ExplodePacket.php | 27 +++++++++++-------- .../network/protocol/StartGamePacket.php | 4 ++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/pocketmine/network/protocol/ExplodePacket.php b/src/pocketmine/network/protocol/ExplodePacket.php index 174268c88..ca2fbf32b 100755 --- a/src/pocketmine/network/protocol/ExplodePacket.php +++ b/src/pocketmine/network/protocol/ExplodePacket.php @@ -45,18 +45,23 @@ public function decode($playerProtocol){ public function encode($playerProtocol){ $this->reset($playerProtocol); - $this->putLFloat($this->x); - $this->putLFloat($this->y); - $this->putLFloat($this->z); - $this->putVarInt((int) ($this->radius * 100)); - $this->putVarInt(count($this->records)); - if(count($this->records) > 0){ - foreach($this->records as $record){ - $this->putSignedVarInt($record->x); - $this->putSignedVarInt($record->y); - $this->putSignedVarInt($record->z); + if ($playerProtocol < Info::PROTOCOL_386) { + $this->putLFloat($this->x); + $this->putLFloat($this->y); + $this->putLFloat($this->z); + $this->putVarInt((int) ($this->radius * 100)); + $this->putVarInt(count($this->records)); + if(count($this->records) > 0){ + foreach($this->records as $record){ + $this->putSignedVarInt($record->x); + $this->putSignedVarInt($record->y); + $this->putSignedVarInt($record->z); + } } + } else { + //Tick sync packet + $this->putLong(0); + $this->putLong(0); } } - } \ No newline at end of file diff --git a/src/pocketmine/network/protocol/StartGamePacket.php b/src/pocketmine/network/protocol/StartGamePacket.php index 10db626da..6846bef4d 100755 --- a/src/pocketmine/network/protocol/StartGamePacket.php +++ b/src/pocketmine/network/protocol/StartGamePacket.php @@ -72,7 +72,9 @@ public function encode($playerProtocol){ $this->putSignedVarInt($this->seed); if ($playerProtocol >= Info::PROTOCOL_400) { - $this->putByte(0);$this->putByte(0); $this->putString(0); + $this->putByte(0); + $this->putByte(0); + $this->putString(''); } $this->putSignedVarInt($this->dimension);