Merge branch 'stable'

# Conflicts:
#	resources/vanilla
#	src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php
#	src/network/mcpe/raklib/FilterTextPacket.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/network/mcpe/protocol/PacketPool.php
#	src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php
This commit is contained in:
Dylan K. Taylor
2020-12-08 21:34:06 +00:00
11 changed files with 217 additions and 11 deletions

View File

@ -71,6 +71,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;
@ -821,4 +822,8 @@ abstract class PacketHandler implements PacketHandlerInterface{
public function handleItemComponent(ItemComponentPacket $packet) : bool{
return false;
}
public function handleFilterText(FilterTextPacket $packet) : bool{
return false;
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
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(PacketSerializer $in) : void{
$this->text = $in->getString();
$this->fromServer = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->text);
$out->putBool($this->fromServer);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleFilterText($this);
}
}

View File

@ -340,4 +340,6 @@ interface PacketHandlerInterface{
public function handleCorrectPlayerMovePrediction(CorrectPlayerMovePredictionPacket $packet) : bool;
public function handleItemComponent(ItemComponentPacket $packet) : bool;
public function handleFilterText(FilterTextPacket $packet) : bool;
}

View File

@ -200,6 +200,7 @@ class PacketPool{
$this->registerPacket(new PlayerFogPacket());
$this->registerPacket(new CorrectPlayerMovePredictionPacket());
$this->registerPacket(new ItemComponentPacket());
$this->registerPacket(new FilterTextPacket());
}
public function registerPacket(Packet $packet) : void{

View File

@ -41,11 +41,11 @@ final class 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;
@ -209,5 +209,6 @@ final class 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;
}

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\resourcepacks\BehaviorPackInfoEntry;
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry;
use function count;
@ -36,14 +37,14 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var bool */
public $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet
/** @var ResourcePackInfoEntry[] */
/** @var BehaviorPackInfoEntry[] */
public $behaviorPackEntries = [];
/** @var ResourcePackInfoEntry[] */
public $resourcePackEntries = [];
/**
* @param ResourcePackInfoEntry[] $resourcePacks
* @param ResourcePackInfoEntry[] $behaviorPacks
* @param BehaviorPackInfoEntry[] $behaviorPacks
*
* @return ResourcePacksInfoPacket
*/
@ -61,7 +62,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
$this->hasScripts = $in->getBool();
$behaviorPackCount = $in->getLShort();
while($behaviorPackCount-- > 0){
$this->behaviorPackEntries[] = ResourcePackInfoEntry::read($in);
$this->behaviorPackEntries[] = BehaviorPackInfoEntry::read($in);
}
$resourcePackCount = $in->getLShort();

View File

@ -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(PacketSerializer $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(PacketSerializer $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);
}
}

View File

@ -0,0 +1,103 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\resourcepacks;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class BehaviorPackInfoEntry{
/** @var string */
private $packId;
/** @var string */
private $version;
/** @var int */
private $sizeBytes;
/** @var string */
private $encryptionKey;
/** @var string */
private $subPackName;
/** @var string */
private $contentId;
/** @var bool */
private $hasScripts;
public function __construct(string $packId, string $version, int $sizeBytes, string $encryptionKey = "", string $subPackName = "", string $contentId = "", bool $hasScripts = false){
$this->packId = $packId;
$this->version = $version;
$this->sizeBytes = $sizeBytes;
$this->encryptionKey = $encryptionKey;
$this->subPackName = $subPackName;
$this->contentId = $contentId;
$this->hasScripts = $hasScripts;
}
public function getPackId() : string{
return $this->packId;
}
public function getVersion() : string{
return $this->version;
}
public function getSizeBytes() : int{
return $this->sizeBytes;
}
public function getEncryptionKey() : string{
return $this->encryptionKey;
}
public function getSubPackName() : string{
return $this->subPackName;
}
public function getContentId() : string{
return $this->contentId;
}
public function hasScripts() : bool{
return $this->hasScripts;
}
public function write(PacketSerializer $out) : void{
$out->putString($this->packId);
$out->putString($this->version);
$out->putLLong($this->sizeBytes);
$out->putString($this->encryptionKey);
$out->putString($this->subPackName);
$out->putString($this->contentId);
$out->putBool($this->hasScripts);
}
public static function read(PacketSerializer $in) : self{
$uuid = $in->getString();
$version = $in->getString();
$sizeBytes = $in->getLLong();
$encryptionKey = $in->getString();
$subPackName = $in->getString();
$contentId = $in->getString();
$hasScripts = $in->getBool();
return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts);
}
}

View File

@ -41,8 +41,10 @@ class ResourcePackInfoEntry{
private $contentId;
/** @var bool */
private $hasScripts;
/** @var bool */
private $isRtxCapable;
public function __construct(string $packId, string $version, int $sizeBytes, string $encryptionKey = "", string $subPackName = "", string $contentId = "", bool $hasScripts = false){
public function __construct(string $packId, string $version, int $sizeBytes, string $encryptionKey = "", string $subPackName = "", string $contentId = "", bool $hasScripts = false, bool $isRtxCapable = false){
$this->packId = $packId;
$this->version = $version;
$this->sizeBytes = $sizeBytes;
@ -50,6 +52,7 @@ class ResourcePackInfoEntry{
$this->subPackName = $subPackName;
$this->contentId = $contentId;
$this->hasScripts = $hasScripts;
$this->isRtxCapable = $isRtxCapable;
}
public function getPackId() : string{
@ -80,6 +83,8 @@ class ResourcePackInfoEntry{
return $this->hasScripts;
}
public function isRtxCapable() : bool{ return $this->isRtxCapable; }
public function write(PacketSerializer $out) : void{
$out->putString($this->packId);
$out->putString($this->version);
@ -88,6 +93,7 @@ class ResourcePackInfoEntry{
$out->putString($this->subPackName);
$out->putString($this->contentId);
$out->putBool($this->hasScripts);
$out->putBool($this->isRtxCapable);
}
public static function read(PacketSerializer $in) : self{
@ -98,6 +104,7 @@ class ResourcePackInfoEntry{
$subPackName = $in->getString();
$contentId = $in->getString();
$hasScripts = $in->getBool();
return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts);
$rtxCapable = $in->getBool();
return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $rtxCapable);
}
}