From 0e90215cfa49e543c0061cfd42ffa5dfaa2a022b Mon Sep 17 00:00:00 2001 From: Dries C Date: Tue, 9 Jul 2024 20:30:44 +0200 Subject: [PATCH 1/2] Protocol changes for 1.21.2 --- src/CloseFormPacket.php | 40 +++++++++++++++++++++++++++ src/PacketHandlerDefaultImplTrait.php | 4 +++ src/PacketHandlerInterface.php | 2 ++ src/PacketPool.php | 1 + src/ProtocolInfo.php | 7 +++-- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/CloseFormPacket.php diff --git a/src/CloseFormPacket.php b/src/CloseFormPacket.php new file mode 100644 index 00000000..6ca323b1 --- /dev/null +++ b/src/CloseFormPacket.php @@ -0,0 +1,40 @@ + + * + * BedrockProtocol is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ + +declare(strict_types=1); + +namespace pocketmine\network\mcpe\protocol; + +use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; + +class CloseFormPacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::CLOSE_FORM_PACKET; + + /** + * @generate-create-func + */ + public static function create() : self{ + return new self; + } + + protected function decodePayload(PacketSerializer $in) : void{ + //No payload + } + + protected function encodePayload(PacketSerializer $out) : void{ + //No payload + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleCloseForm($this); + } +} diff --git a/src/PacketHandlerDefaultImplTrait.php b/src/PacketHandlerDefaultImplTrait.php index 7576ffcf..9dcb6d30 100644 --- a/src/PacketHandlerDefaultImplTrait.php +++ b/src/PacketHandlerDefaultImplTrait.php @@ -801,4 +801,8 @@ public function handleSetHud(SetHudPacket $packet) : bool{ public function handleAwardAchievement(AwardAchievementPacket $packet) : bool{ return false; } + + public function handleCloseForm(CloseFormPacket $packet) : bool{ + return false; + } } diff --git a/src/PacketHandlerInterface.php b/src/PacketHandlerInterface.php index e1a75093..6c7ebeb5 100644 --- a/src/PacketHandlerInterface.php +++ b/src/PacketHandlerInterface.php @@ -407,4 +407,6 @@ public function handleSetPlayerInventoryOptions(SetPlayerInventoryOptionsPacket public function handleSetHud(SetHudPacket $packet) : bool; public function handleAwardAchievement(AwardAchievementPacket $packet) : bool; + + public function handleCloseForm(CloseFormPacket $packet) : bool; } diff --git a/src/PacketPool.php b/src/PacketPool.php index 7ee90812..73a1eea0 100644 --- a/src/PacketPool.php +++ b/src/PacketPool.php @@ -228,6 +228,7 @@ public function __construct(){ $this->registerPacket(new SetPlayerInventoryOptionsPacket()); $this->registerPacket(new SetHudPacket()); $this->registerPacket(new AwardAchievementPacket()); + $this->registerPacket(new CloseFormPacket()); } public function registerPacket(Packet $packet) : void{ diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index bcab3cca..1aa50bec 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -32,11 +32,11 @@ private function __construct(){ */ /** Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 685; + public const CURRENT_PROTOCOL = 686; /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.21.0'; + public const MINECRAFT_VERSION = 'v1.21.2'; /** Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.21.0'; + public const MINECRAFT_VERSION_NETWORK = '1.21.2'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -245,5 +245,6 @@ private function __construct(){ public const SET_PLAYER_INVENTORY_OPTIONS_PACKET = 0x133; public const SET_HUD_PACKET = 0x134; public const AWARD_ACHIEVEMENT_PACKET = 0x135; + public const CLOSE_FORM_PACKET = 0x136; } From bb23db51365bdc91d3135c3885986a691ae1cb44 Mon Sep 17 00:00:00 2001 From: Dries C Date: Wed, 10 Jul 2024 03:38:43 +0200 Subject: [PATCH 2/2] Rename CloseFormPacket to ClientboundCloseFormPacket (#248) Parity with vanilla protocol convention --- src/{CloseFormPacket.php => ClientboundCloseFormPacket.php} | 4 ++-- src/PacketHandlerDefaultImplTrait.php | 2 +- src/PacketHandlerInterface.php | 2 +- src/PacketPool.php | 2 +- src/ProtocolInfo.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename src/{CloseFormPacket.php => ClientboundCloseFormPacket.php} (85%) diff --git a/src/CloseFormPacket.php b/src/ClientboundCloseFormPacket.php similarity index 85% rename from src/CloseFormPacket.php rename to src/ClientboundCloseFormPacket.php index 6ca323b1..c6eb8e34 100644 --- a/src/CloseFormPacket.php +++ b/src/ClientboundCloseFormPacket.php @@ -16,8 +16,8 @@ use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -class CloseFormPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLOSE_FORM_PACKET; +class ClientboundCloseFormPacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_CLOSE_FORM_PACKET; /** * @generate-create-func diff --git a/src/PacketHandlerDefaultImplTrait.php b/src/PacketHandlerDefaultImplTrait.php index 9dcb6d30..9cedf25a 100644 --- a/src/PacketHandlerDefaultImplTrait.php +++ b/src/PacketHandlerDefaultImplTrait.php @@ -802,7 +802,7 @@ public function handleAwardAchievement(AwardAchievementPacket $packet) : bool{ return false; } - public function handleCloseForm(CloseFormPacket $packet) : bool{ + public function handleCloseForm(ClientboundCloseFormPacket $packet) : bool{ return false; } } diff --git a/src/PacketHandlerInterface.php b/src/PacketHandlerInterface.php index 6c7ebeb5..107c6b2f 100644 --- a/src/PacketHandlerInterface.php +++ b/src/PacketHandlerInterface.php @@ -408,5 +408,5 @@ public function handleSetHud(SetHudPacket $packet) : bool; public function handleAwardAchievement(AwardAchievementPacket $packet) : bool; - public function handleCloseForm(CloseFormPacket $packet) : bool; + public function handleCloseForm(ClientboundCloseFormPacket $packet) : bool; } diff --git a/src/PacketPool.php b/src/PacketPool.php index 73a1eea0..b48bd757 100644 --- a/src/PacketPool.php +++ b/src/PacketPool.php @@ -228,7 +228,7 @@ public function __construct(){ $this->registerPacket(new SetPlayerInventoryOptionsPacket()); $this->registerPacket(new SetHudPacket()); $this->registerPacket(new AwardAchievementPacket()); - $this->registerPacket(new CloseFormPacket()); + $this->registerPacket(new ClientboundCloseFormPacket()); } public function registerPacket(Packet $packet) : void{ diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index 1aa50bec..4df23820 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -245,6 +245,6 @@ private function __construct(){ public const SET_PLAYER_INVENTORY_OPTIONS_PACKET = 0x133; public const SET_HUD_PACKET = 0x134; public const AWARD_ACHIEVEMENT_PACKET = 0x135; - public const CLOSE_FORM_PACKET = 0x136; + public const CLIENTBOUND_CLOSE_FORM_PACKET = 0x136; }