From 7b152def7db154ef86c4581062e0f4d1ab79d9c1 Mon Sep 17 00:00:00 2001 From: Stephen Date: Mon, 11 Nov 2019 15:23:48 -0500 Subject: [PATCH] Move SkinAnimation and changed SerializedImage to SkinImage Also change putImage and getImage to getSkinImage and putSkinImage --- src/pocketmine/Player.php | 2 -- .../network/mcpe/NetworkBinaryStream.php | 22 +++++++++---------- .../mcpe/protocol/PlayerSkinPacket.php | 2 -- .../mcpe/protocol/types}/SkinAnimation.php | 10 ++++----- .../mcpe/protocol/types/SkinImage.php} | 6 ++--- 5 files changed, 19 insertions(+), 23 deletions(-) rename src/pocketmine/{utils => network/mcpe/protocol/types}/SkinAnimation.php (86%) rename src/pocketmine/{utils/SerializedImage.php => network/mcpe/protocol/types/SkinImage.php} (92%) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f3930e136b..c70e177721 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -160,8 +160,6 @@ use pocketmine\tile\ItemFrame; use pocketmine\tile\Spawnable; use pocketmine\tile\Tile; use pocketmine\timings\Timings; -use pocketmine\utils\SerializedImage; -use pocketmine\utils\SkinAnimation; use pocketmine\utils\TextFormat; use pocketmine\utils\UUID; use function abs; diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 890a57a19b..c05b365bfb 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -38,10 +38,10 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\network\mcpe\protocol\types\CommandOriginData; use pocketmine\network\mcpe\protocol\types\EntityLink; +use pocketmine\network\mcpe\protocol\types\SkinImage; +use pocketmine\network\mcpe\protocol\types\SkinAnimation; use pocketmine\network\mcpe\protocol\types\StructureSettings; use pocketmine\utils\BinaryStream; -use pocketmine\utils\SerializedImage; -use pocketmine\utils\SkinAnimation; use pocketmine\utils\UUID; use function count; use function strlen; @@ -80,13 +80,13 @@ class NetworkBinaryStream extends BinaryStream{ public function getSkin() : Skin{ $skinId = $this->getString(); $skinResourcePatch = $this->getString(); - $skinData = $this->getImage(); + $skinData = $this->getSkinImage(); $animationCount = $this->getLInt(); $animations = []; for($i = 0; $i < $animationCount; ++$i){ - $animations[] = new SkinAnimation($this->getImage(), $this->getLInt(), $this->getLFloat()); + $animations[] = new SkinAnimation($this->getSkinImage(), $this->getLInt(), $this->getLFloat()); } - $capeData = $this->getImage(); + $capeData = $this->getSkinImage(); $geometryData = $this->getString(); $animationData = $this->getString(); $premium = $this->getBool(); @@ -101,16 +101,16 @@ class NetworkBinaryStream extends BinaryStream{ public function putSkin(Skin $skin){ $this->putString($skin->getSkinId()); $this->putString($skin->getGeometryName()); //resource patch - $this->putImage(SerializedImage::fromLegacy($skin->getSkinData())); + $this->putSkinImage(SkinImage::fromLegacy($skin->getSkinData())); /** @var SkinAnimation[] $animations */ $animations = []; $this->putLInt(count($animations)); foreach($animations as $animation){ - $this->putImage($animation->getImage()); + $this->putSkinImage($animation->getImage()); $this->putLInt($animation->getType()); $this->putLFloat($animation->getFrames()); } - $this->putImage(new SerializedImage(0, 0, $skin->getCapeData())); + $this->putSkinImage(new SkinImage(0, 0, $skin->getCapeData())); $this->putString($skin->getGeometryData()); $this->putString(""); //animation data $this->putBool(false); //isPremium @@ -120,14 +120,14 @@ class NetworkBinaryStream extends BinaryStream{ $this->putString(""); //fullskinId } - public function getImage() : SerializedImage{ + public function getSkinImage() : SkinImage{ $width = $this->getLInt(); $height = $this->getLInt(); $data = $this->getString(); - return new SerializedImage($height, $width, $data); + return new SkinImage($height, $width, $data); } - public function putImage(SerializedImage $image) : void{ + public function putSkinImage(SkinImage $image) : void{ $this->putLInt($image->getWidth()); $this->putLInt($image->getHeight()); $this->putString($image->getData()); diff --git a/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php index bbe513bd69..219e7fbf0c 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php @@ -27,8 +27,6 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\entity\Skin; use pocketmine\network\mcpe\NetworkSession; -use pocketmine\utils\SerializedImage; -use pocketmine\utils\SkinAnimation; use pocketmine\utils\UUID; class PlayerSkinPacket extends DataPacket{ diff --git a/src/pocketmine/utils/SkinAnimation.php b/src/pocketmine/network/mcpe/protocol/types/SkinAnimation.php similarity index 86% rename from src/pocketmine/utils/SkinAnimation.php rename to src/pocketmine/network/mcpe/protocol/types/SkinAnimation.php index b35c41cea1..0f6726cf7c 100644 --- a/src/pocketmine/utils/SkinAnimation.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinAnimation.php @@ -21,7 +21,7 @@ declare(strict_types=1); -namespace pocketmine\utils; +namespace pocketmine\network\mcpe\protocol\types; class SkinAnimation{ @@ -29,14 +29,14 @@ class SkinAnimation{ public const TYPE_BODY_32 = 2; public const TYPE_BODY_64 = 3; - /** @var SerializedImage */ + /** @var SkinImage */ private $image; /** @var int */ private $type; /** @var float */ private $frames; - public function __construct(SerializedImage $image, int $type, float $frames){ + public function __construct(SkinImage $image, int $type, float $frames){ $this->image = $image; $this->type = $type; $this->frames = $frames; @@ -45,9 +45,9 @@ class SkinAnimation{ /** * Image of the animation. * - * @return SerializedImage + * @return SkinImage */ - public function getImage() : SerializedImage{ + public function getImage() : SkinImage{ return $this->image; } diff --git a/src/pocketmine/utils/SerializedImage.php b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php similarity index 92% rename from src/pocketmine/utils/SerializedImage.php rename to src/pocketmine/network/mcpe/protocol/types/SkinImage.php index 6996e22083..cbd7ebc16b 100644 --- a/src/pocketmine/utils/SerializedImage.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php @@ -21,9 +21,9 @@ declare(strict_types=1); -namespace pocketmine\utils; +namespace pocketmine\network\mcpe\protocol\types; -class SerializedImage{ +class SkinImage{ /** @var int */ private $height; @@ -38,7 +38,7 @@ class SerializedImage{ $this->data = $data; } - public static function fromLegacy(string $data) : SerializedImage{ + public static function fromLegacy(string $data) : SkinImage{ switch(strlen($data)){ case 64 * 32 * 4: return new self(64, 32, $data);