From 692e63ad7cf2c97a3a85f60fc45f7816593b3cbe Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 8 Dec 2020 20:31:17 +0000 Subject: [PATCH] Protocol changes for 1.16.200 --- .../network/mcpe/NetworkSession.php | 5 ++ .../mcpe/protocol/FilterTextPacket.php | 62 +++++++++++++++++++ .../network/mcpe/protocol/PacketPool.php | 1 + .../network/mcpe/protocol/ProtocolInfo.php | 7 ++- .../mcpe/protocol/ResourcePacksInfoPacket.php | 2 + .../ItemStackResponseSlotInfo.php | 11 +++- src/pocketmine/resources/vanilla | 2 +- 7 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/pocketmine/network/mcpe/protocol/FilterTextPacket.php diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index dfb39796f..f6b6cecbe 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -72,6 +72,7 @@ use pocketmine\network\mcpe\protocol\EducationSettingsPacket; use pocketmine\network\mcpe\protocol\EmoteListPacket; use pocketmine\network\mcpe\protocol\EmotePacket; use pocketmine\network\mcpe\protocol\EventPacket; +use pocketmine\network\mcpe\protocol\FilterTextPacket; use pocketmine\network\mcpe\protocol\GameRulesChangedPacket; use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket; use pocketmine\network\mcpe\protocol\HurtArmorPacket; @@ -816,4 +817,8 @@ abstract class NetworkSession{ public function handleItemComponent(ItemComponentPacket $packet) : bool{ return false; } + + public function handleFilterText(FilterTextPacket $packet) : bool{ + return false; + } } diff --git a/src/pocketmine/network/mcpe/protocol/FilterTextPacket.php b/src/pocketmine/network/mcpe/protocol/FilterTextPacket.php new file mode 100644 index 000000000..84f81dc81 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/FilterTextPacket.php @@ -0,0 +1,62 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class FilterTextPacket extends DataPacket/* implements ClientboundPacket, ServerboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::FILTER_TEXT_PACKET; + + /** @var string */ + private $text; + /** @var bool */ + private $fromServer; + + public static function create(string $text, bool $server) : self{ + $result = new self; + $result->text = $text; + $result->fromServer = $server; + return $result; + } + + public function getText() : string{ return $this->text; } + + public function isFromServer() : bool{ return $this->fromServer; } + + protected function decodePayload() : void{ + $this->text = $this->getString(); + $this->fromServer = $this->getBool(); + } + + protected function encodePayload() : void{ + $this->putString($this->text); + $this->putBool($this->fromServer); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleFilterText($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/PacketPool.php b/src/pocketmine/network/mcpe/protocol/PacketPool.php index f46cbc80f..b0e912a15 100644 --- a/src/pocketmine/network/mcpe/protocol/PacketPool.php +++ b/src/pocketmine/network/mcpe/protocol/PacketPool.php @@ -193,6 +193,7 @@ class PacketPool{ static::registerPacket(new PlayerFogPacket()); static::registerPacket(new CorrectPlayerMovePredictionPacket()); static::registerPacket(new ItemComponentPacket()); + static::registerPacket(new FilterTextPacket()); } /** diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index d186a0f12..28f421b04 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -37,11 +37,11 @@ interface ProtocolInfo{ */ /** Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 419; + public const CURRENT_PROTOCOL = 422; /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.16.100'; + public const MINECRAFT_VERSION = 'v1.16.200'; /** Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.16.100'; + public const MINECRAFT_VERSION_NETWORK = '1.16.200'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -205,5 +205,6 @@ interface ProtocolInfo{ public const PLAYER_FOG_PACKET = 0xa0; public const CORRECT_PLAYER_MOVE_PREDICTION_PACKET = 0xa1; public const ITEM_COMPONENT_PACKET = 0xa2; + public const FILTER_TEXT_PACKET = 0xa3; } diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php index 0144587c8..714382dea 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php @@ -64,6 +64,7 @@ class ResourcePacksInfoPacket extends DataPacket{ $this->getString(); $this->getString(); $this->getBool(); + $this->getBool(); } } @@ -89,6 +90,7 @@ class ResourcePacksInfoPacket extends DataPacket{ $this->putString(""); //TODO: subpack name $this->putString(""); //TODO: content identity $this->putBool(false); //TODO: seems useless for resource packs + $this->putBool(false); //TODO: supports RTX } } diff --git a/src/pocketmine/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php b/src/pocketmine/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php index f8ac0a781..db290c332 100644 --- a/src/pocketmine/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php +++ b/src/pocketmine/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php @@ -35,12 +35,15 @@ final class ItemStackResponseSlotInfo{ private $count; /** @var int */ private $itemStackId; + /** @var string */ + private $customName; - public function __construct(int $slot, int $hotbarSlot, int $count, int $itemStackId){ + public function __construct(int $slot, int $hotbarSlot, int $count, int $itemStackId, string $customName){ $this->slot = $slot; $this->hotbarSlot = $hotbarSlot; $this->count = $count; $this->itemStackId = $itemStackId; + $this->customName = $customName; } public function getSlot() : int{ return $this->slot; } @@ -51,12 +54,15 @@ final class ItemStackResponseSlotInfo{ public function getItemStackId() : int{ return $this->itemStackId; } + public function getCustomName() : string{ return $this->customName; } + public static function read(NetworkBinaryStream $in) : self{ $slot = $in->getByte(); $hotbarSlot = $in->getByte(); $count = $in->getByte(); $itemStackId = $in->readGenericTypeNetworkId(); - return new self($slot, $hotbarSlot, $count, $itemStackId); + $customName = $in->getString(); + return new self($slot, $hotbarSlot, $count, $itemStackId, $customName); } public function write(NetworkBinaryStream $out) : void{ @@ -64,5 +70,6 @@ final class ItemStackResponseSlotInfo{ $out->putByte($this->hotbarSlot); $out->putByte($this->count); $out->writeGenericTypeNetworkId($this->itemStackId); + $out->putString($this->customName); } } diff --git a/src/pocketmine/resources/vanilla b/src/pocketmine/resources/vanilla index 14f4a765e..4e58a3c67 160000 --- a/src/pocketmine/resources/vanilla +++ b/src/pocketmine/resources/vanilla @@ -1 +1 @@ -Subproject commit 14f4a765eba40b2c65c6dcd061cbfea6e1d3d4cc +Subproject commit 4e58a3c67dea62600ce5fd014b9fd792a50d246d