diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 96c7b8c9f2..2478d5b26f 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -104,22 +104,22 @@ class NetworkBinaryStream extends BinaryStream{ } public function putSkin(SkinData $skin){ - $this->putString($skin->skinId); - $this->putString($skin->resourcePatch); //resource patch - $this->putSkinImage($skin->skinImage); - $this->putLInt(count($skin->animations)); - foreach($skin->animations as $animation){ + $this->putString($skin->getSkinId()); + $this->putString($skin->getResourcePatch()); + $this->putSkinImage($skin->getSkinImage()); + $this->putLInt(count($skin->getAnimations())); + foreach($skin->getAnimations() as $animation){ $this->putSkinImage($animation->getImage()); $this->putLInt($animation->getType()); $this->putLFloat($animation->getFrames()); } - $this->putSkinImage($skin->capeImage); - $this->putString($skin->geometryData); - $this->putString($skin->animationData); - $this->putBool($skin->premium); - $this->putBool($skin->persona); - $this->putBool($skin->capeOnClassic); - $this->putString($skin->capeId); + $this->putSkinImage($skin->getCapeImage()); + $this->putString($skin->getGeometryData()); + $this->putString($skin->getAnimationData()); + $this->putBool($skin->isPremium()); + $this->putBool($skin->isPersona()); + $this->putBool($skin->isPersonaCapeOnClassic()); + $this->putString($skin->getCapeId()); //this has to be unique or the client will do stupid things $this->putString(UUID::fromRandom()->toString()); //full skin ID diff --git a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php index 47997f2359..f73abb2540 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php @@ -60,7 +60,7 @@ class PlayerListPacket extends DataPacket{ $entry->xboxUserId = $this->getString(); $entry->platformChatId = $this->getString(); $entry->buildPlatform = $this->getLInt(); - $entry->skin = $this->getSkin(); + $entry->skinData = $this->getSkin(); $entry->isTeacher = $this->getBool(); $entry->isHost = $this->getBool(); }else{ diff --git a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php index 721acd8a66..0fb85414ad 100644 --- a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php +++ b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php @@ -32,10 +32,10 @@ class LegacySkinAdapter implements SkinAdapter{ } public function fromSkinData(SkinData $data) : Skin{ - $skinData = $data->skinImage->getData(); - if($data->persona){ - $skinData = str_repeat(random_bytes(3) . "\xff", 2048); + $skinData = $data->getSkinImage()->getData(); + if($data->isPersona()){ + return new Skin("Standard_Custom", str_repeat(random_bytes(3) . "\xff", 2048), "", "geometry.humanoid.custom"); } - return new Skin($data->skinId, $skinData, $data->capeImage->getData(), json_decode($data->resourcePatch, true)["geometry"]["default"], $data->geometryData); + return new Skin($data->getSkinId(), $skinData, $data->getCapeImage()->getData(), json_decode($data->getResourcePatch(), true)["geometry"]["default"], $data->getGeometryData()); } } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/types/SkinData.php b/src/pocketmine/network/mcpe/protocol/types/SkinData.php index ea356eea34..65d3af76e0 100644 --- a/src/pocketmine/network/mcpe/protocol/types/SkinData.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinData.php @@ -26,29 +26,29 @@ namespace pocketmine\network\mcpe\protocol\types; class SkinData{ /** @var string */ - public $skinId; + private $skinId; /** @var string */ - public $resourcePatch; + private $resourcePatch; /** @var SkinImage */ - public $skinImage; + private $skinImage; /** @var SkinAnimation[] */ - public $animations; + private $animations; /** @var SkinImage */ - public $capeImage; + private $capeImage; /** @var string */ - public $geometryData; + private $geometryData; /** @var string */ - public $animationData; + private $animationData; /** @var bool */ - public $persona; + private $persona; /** @var bool */ - public $premium; + private $premium; /** @var bool */ - public $capeOnClassic; + private $personaCapeOnClassic; /** @var string */ - public $capeId; + private $capeId; - public function __construct(string $skinId, string $resourcePatch, SkinImage $skinImage, array $animations = [], SkinImage $capeImage = null, string $geometryData = "", string $animationData = "", bool $premium = false, bool $persona = false, bool $capeOnClassic = false, string $capeId = ""){ + public function __construct(string $skinId, string $resourcePatch, SkinImage $skinImage, array $animations = [], SkinImage $capeImage = null, string $geometryData = "", string $animationData = "", bool $premium = false, bool $persona = false, bool $personaCapeOnClassic = false, string $capeId = ""){ $this->skinId = $skinId; $this->resourcePatch = $resourcePatch; $this->skinImage = $skinImage; @@ -58,7 +58,85 @@ class SkinData{ $this->animationData = $animationData; $this->premium = $premium; $this->persona = $persona; - $this->capeOnClassic = $capeOnClassic; + $this->personaCapeOnClassic = $personaCapeOnClassic; $this->capeId = $capeId; } + + /** + * @return string + */ + public function getSkinId() : string{ + return $this->skinId; + } + + /** + * @return string + */ + public function getResourcePatch() : string{ + return $this->resourcePatch; + } + + /** + * @return SkinImage + */ + public function getSkinImage() : SkinImage{ + return $this->skinImage; + } + + /** + * @return SkinAnimation[] + */ + public function getAnimations() : array{ + return $this->animations; + } + + /** + * @return SkinImage + */ + public function getCapeImage() : SkinImage{ + return $this->capeImage; + } + + /** + * @return string + */ + public function getGeometryData() : string{ + return $this->geometryData; + } + + /** + * @return string + */ + public function getAnimationData() : string{ + return $this->animationData; + } + + /** + * @return bool + */ + public function isPersona() : bool{ + return $this->persona; + } + + /** + * @return bool + */ + public function isPremium() : bool{ + return $this->premium; + } + + /** + * @return bool + */ + public function isPersonaCapeOnClassic() : bool{ + return $this->personaCapeOnClassic; + } + + /** + * @return string + */ + public function getCapeId() : string{ + return $this->capeId; + } + } \ No newline at end of file