From 5045157bcbe89633b2bb6a9b6fa23c47292d6bd1 Mon Sep 17 00:00:00 2001 From: AkmalFairuz Date: Thu, 26 Oct 2023 22:06:21 +0700 Subject: [PATCH] 1.19.40 --- src/DisconnectPacket.php | 8 ++++++-- src/ProtocolInfo.php | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DisconnectPacket.php b/src/DisconnectPacket.php index 80a3faed..95812fc8 100644 --- a/src/DisconnectPacket.php +++ b/src/DisconnectPacket.php @@ -37,7 +37,9 @@ public function canBeSentBeforeLogin() : bool{ } protected function decodePayload(PacketSerializer $in) : void{ - $this->reason = $in->getVarInt(); + if($in->getProtocol() >= ProtocolInfo::PROTOCOL_622){ + $this->reason = $in->getVarInt(); + } $hideDisconnectionScreen = $in->getBool(); if(!$hideDisconnectionScreen){ $this->message = $in->getString(); @@ -45,7 +47,9 @@ protected function decodePayload(PacketSerializer $in) : void{ } protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->reason); + if($out->getProtocol() >= ProtocolInfo::PROTOCOL_622){ + $out->putVarInt($this->reason); + } $out->putBool($this->message === null); if($this->message !== null){ $out->putString($this->message); diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index 90d15508..24d0c5ff 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -40,6 +40,7 @@ private function __construct(){ public const BASE_VERSION = '1.18.0'; + public const PROTOCOL_622 = 622; // 1.20.40 public const PROTOCOL_618 = 618; // 1.20.30 public const PROTOCOL_594 = 594; // 1.20.10 public const PROTOCOL_589 = 589; // 1.20.0 @@ -59,6 +60,7 @@ private function __construct(){ public const PROTOCOL_475 = 475; // v1.18.0 public const COMPATIBLE_PROTOCOL = [ + self::PROTOCOL_622, self::PROTOCOL_618, self::PROTOCOL_594, self::PROTOCOL_589,