mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-24 06:24:41 +00:00
Clean up duplicated skin entries
This commit is contained in:
parent
3b7ded0ba3
commit
5b11ddee35
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe;
|
|||||||
|
|
||||||
use pocketmine\entity\Attribute;
|
use pocketmine\entity\Attribute;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\entity\Skin;
|
||||||
use pocketmine\item\Durable;
|
use pocketmine\item\Durable;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\ItemFactory;
|
||||||
@ -40,6 +41,7 @@ use pocketmine\network\mcpe\protocol\types\EntityLink;
|
|||||||
use pocketmine\network\mcpe\protocol\types\StructureSettings;
|
use pocketmine\network\mcpe\protocol\types\StructureSettings;
|
||||||
use pocketmine\utils\BinaryStream;
|
use pocketmine\utils\BinaryStream;
|
||||||
use pocketmine\utils\SerializedImage;
|
use pocketmine\utils\SerializedImage;
|
||||||
|
use pocketmine\utils\SkinAnimation;
|
||||||
use pocketmine\utils\UUID;
|
use pocketmine\utils\UUID;
|
||||||
use function count;
|
use function count;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
@ -75,10 +77,47 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
$this->putLInt($uuid->getPart(2));
|
$this->putLInt($uuid->getPart(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function putImage(SerializedImage $image) : void{
|
public function getSkin() : Skin{
|
||||||
$this->putLInt($image->getWidth());
|
$skinId = $this->getString();
|
||||||
$this->putLInt($image->getHeight());
|
$skinResourcePatch = $this->getString();
|
||||||
$this->putString($image->getData());
|
$skinData = $this->getImage();
|
||||||
|
$animationCount = $this->getLInt();
|
||||||
|
$animations = [];
|
||||||
|
for($i = 0; $i < $animationCount; ++$i){
|
||||||
|
$animations[] = new SkinAnimation($this->getImage(), $this->getLInt(), $this->getLFloat());
|
||||||
|
}
|
||||||
|
$capeData = $this->getImage();
|
||||||
|
$geometryData = $this->getString();
|
||||||
|
$animationData = $this->getString();
|
||||||
|
$premium = $this->getBool();
|
||||||
|
$persona = $this->getBool();
|
||||||
|
$capeOnClassic = $this->getBool();
|
||||||
|
$capeId = $this->getString();
|
||||||
|
$fullSkinId = $this->getString();
|
||||||
|
|
||||||
|
return new Skin(
|
||||||
|
$skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function putSkin(Skin $skin){
|
||||||
|
$this->putString($skin->getSkinId());
|
||||||
|
$this->putString($skin->getSkinResourcePatch());
|
||||||
|
$this->putImage($skin->getSkinData());
|
||||||
|
$this->putLInt(count($skin->getAnimations()));
|
||||||
|
foreach($skin->getAnimations() as $animation){
|
||||||
|
$this->putImage($animation->getImage());
|
||||||
|
$this->putLInt($animation->getType());
|
||||||
|
$this->putLFloat($animation->getFrames());
|
||||||
|
}
|
||||||
|
$this->putImage($skin->getCapeData());
|
||||||
|
$this->putString($skin->getGeometryData());
|
||||||
|
$this->putString($skin->getAnimationData());
|
||||||
|
$this->putBool($skin->getPremium());
|
||||||
|
$this->putBool($skin->getPersona());
|
||||||
|
$this->putBool($skin->getCapeOnClassic());
|
||||||
|
$this->putString($skin->getCapeId());
|
||||||
|
$this->putString($skin->getFullSkinId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImage() : SerializedImage{
|
public function getImage() : SerializedImage{
|
||||||
@ -88,6 +127,12 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
return new SerializedImage($height, $width, $data);
|
return new SerializedImage($height, $width, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function putImage(SerializedImage $image) : void{
|
||||||
|
$this->putLInt($image->getWidth());
|
||||||
|
$this->putLInt($image->getHeight());
|
||||||
|
$this->putString($image->getData());
|
||||||
|
}
|
||||||
|
|
||||||
public function getSlot() : Item{
|
public function getSlot() : Item{
|
||||||
$id = $this->getVarInt();
|
$id = $this->getVarInt();
|
||||||
if($id === 0){
|
if($id === 0){
|
||||||
|
@ -62,28 +62,7 @@ class PlayerListPacket extends DataPacket{
|
|||||||
$entry->xboxUserId = $this->getString();
|
$entry->xboxUserId = $this->getString();
|
||||||
$entry->platformChatId = $this->getString();
|
$entry->platformChatId = $this->getString();
|
||||||
$entry->buildPlatform = $this->getLInt();
|
$entry->buildPlatform = $this->getLInt();
|
||||||
|
$entry->skin = $this->getSkin();
|
||||||
$skinId = $this->getString();
|
|
||||||
$skinResourcePatch = $this->getString();
|
|
||||||
$skinData = $this->getImage();
|
|
||||||
$animationCount = $this->getLInt();
|
|
||||||
$animations = [];
|
|
||||||
for($i = 0; $i < $animationCount; ++$i){
|
|
||||||
$animations[] = new SkinAnimation($this->getImage(), $this->getLInt(), $this->getLFloat());
|
|
||||||
}
|
|
||||||
$capeData = $this->getImage();
|
|
||||||
$geometryData = $this->getString();
|
|
||||||
$animationData = $this->getString();
|
|
||||||
$premium = $this->getBool();
|
|
||||||
$persona = $this->getBool();
|
|
||||||
$capeOnClassic = $this->getBool();
|
|
||||||
$capeId = $this->getString();
|
|
||||||
$fullSkinId = $this->getString();
|
|
||||||
|
|
||||||
$entry->skin = new Skin(
|
|
||||||
$skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId
|
|
||||||
);
|
|
||||||
|
|
||||||
$entry->isTeacher = $this->getBool();
|
$entry->isTeacher = $this->getBool();
|
||||||
$entry->isHost = $this->getBool();
|
$entry->isHost = $this->getBool();
|
||||||
}else{
|
}else{
|
||||||
@ -105,25 +84,7 @@ class PlayerListPacket extends DataPacket{
|
|||||||
$this->putString($entry->xboxUserId);
|
$this->putString($entry->xboxUserId);
|
||||||
$this->putString($entry->platformChatId);
|
$this->putString($entry->platformChatId);
|
||||||
$this->putLInt($entry->buildPlatform);
|
$this->putLInt($entry->buildPlatform);
|
||||||
|
$this->putSkin($entry->skin);
|
||||||
$this->putString($entry->skin->getSkinId());
|
|
||||||
$this->putString($entry->skin->getSkinResourcePatch());
|
|
||||||
$this->putImage($entry->skin->getSkinData());
|
|
||||||
$this->putLInt(count($entry->skin->getAnimations()));
|
|
||||||
foreach($entry->skin->getAnimations() as $animation){
|
|
||||||
$this->putImage($animation->getImage());
|
|
||||||
$this->putLInt($animation->getType());
|
|
||||||
$this->putLFloat($animation->getFrames());
|
|
||||||
}
|
|
||||||
$this->putImage($entry->skin->getCapeData());
|
|
||||||
$this->putString($entry->skin->getGeometryData());
|
|
||||||
$this->putString($entry->skin->getAnimationData());
|
|
||||||
$this->putBool($entry->skin->getPremium());
|
|
||||||
$this->putBool($entry->skin->getPersona());
|
|
||||||
$this->putBool($entry->skin->getCapeOnClassic());
|
|
||||||
$this->putString($entry->skin->getCapeId());
|
|
||||||
$this->putString($entry->skin->getFullSkinId());
|
|
||||||
|
|
||||||
$this->putBool($entry->isTeacher);
|
$this->putBool($entry->isTeacher);
|
||||||
$this->putBool($entry->isHost);
|
$this->putBool($entry->isHost);
|
||||||
}else{
|
}else{
|
||||||
|
@ -41,49 +41,12 @@ class PlayerSkinPacket extends DataPacket{
|
|||||||
|
|
||||||
protected function decodePayload(){
|
protected function decodePayload(){
|
||||||
$this->uuid = $this->getUUID();
|
$this->uuid = $this->getUUID();
|
||||||
|
$this->skin = $this->getSkin();
|
||||||
$skinId = $this->getString();
|
|
||||||
$skinResourcePatch = $this->getString();
|
|
||||||
$skinData = $this->getImage();
|
|
||||||
$animationCount = $this->getLInt();
|
|
||||||
$animations = [];
|
|
||||||
for($i = 0; $i < $animationCount; ++$i){
|
|
||||||
$animations[] = new SkinAnimation($this->getImage(), $this->getLInt(), $this->getLFloat());
|
|
||||||
}
|
|
||||||
$capeData = $this->getImage();
|
|
||||||
$geometryData = $this->getString();
|
|
||||||
$animationData = $this->getString();
|
|
||||||
$premium = $this->getBool();
|
|
||||||
$persona = $this->getBool();
|
|
||||||
$capeOnClassic = $this->getBool();
|
|
||||||
$capeId = $this->getString();
|
|
||||||
$fullSkinId = $this->getString();
|
|
||||||
|
|
||||||
$this->skin = new Skin(
|
|
||||||
$skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function encodePayload(){
|
protected function encodePayload(){
|
||||||
$this->putUUID($this->uuid);
|
$this->putUUID($this->uuid);
|
||||||
|
$this->putSkin($this->skin);
|
||||||
$this->putString($this->skin->getSkinId());
|
|
||||||
$this->putString($this->skin->getSkinResourcePatch());
|
|
||||||
$this->putImage($this->skin->getSkinData());
|
|
||||||
$this->putLInt(count($this->skin->getAnimations()));
|
|
||||||
foreach($this->skin->getAnimations() as $animation){
|
|
||||||
$this->putImage($animation->getImage());
|
|
||||||
$this->putLInt($animation->getType());
|
|
||||||
$this->putLFloat($animation->getFrames());
|
|
||||||
}
|
|
||||||
$this->putImage($this->skin->getCapeData());
|
|
||||||
$this->putString($this->skin->getGeometryData());
|
|
||||||
$this->putString($this->skin->getAnimationData());
|
|
||||||
$this->putBool($this->skin->getPremium());
|
|
||||||
$this->putBool($this->skin->getPersona());
|
|
||||||
$this->putBool($this->skin->getCapeOnClassic());
|
|
||||||
$this->putString($this->skin->getCapeId());
|
|
||||||
$this->putString($this->skin->getFullSkinId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(NetworkSession $session) : bool{
|
public function handle(NetworkSession $session) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user