mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Merge branch 'stable' of https://github.com/drew-mcbe/pocketmine-mp into drew-1.13
This commit is contained in:
@ -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,17 @@ 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(
|
||||
$skinImage = $this->getSkinImage(),
|
||||
$animationType = $this->getLInt(),
|
||||
$animationFrames = $this->getLFloat()
|
||||
);
|
||||
}
|
||||
$capeData = $this->getImage();
|
||||
$capeData = $this->getSkinImage();
|
||||
$geometryData = $this->getString();
|
||||
$animationData = $this->getString();
|
||||
$premium = $this->getBool();
|
||||
@ -101,16 +105,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 +124,14 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putString(""); //fullskinId
|
||||
}
|
||||
|
||||
public function getImage() : SerializedImage{
|
||||
private 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{
|
||||
private function putSkinImage(SkinImage $image) : void{
|
||||
$this->putLInt($image->getWidth());
|
||||
$this->putLInt($image->getHeight());
|
||||
$this->putString($image->getData());
|
||||
|
@ -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{
|
||||
|
71
src/pocketmine/network/mcpe/protocol/types/SkinAnimation.php
Normal file
71
src/pocketmine/network/mcpe/protocol/types/SkinAnimation.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
|
||||
class SkinAnimation{
|
||||
|
||||
public const TYPE_HEAD = 1;
|
||||
public const TYPE_BODY_32 = 2;
|
||||
public const TYPE_BODY_64 = 3;
|
||||
|
||||
/** @var SkinImage */
|
||||
private $image;
|
||||
/** @var int */
|
||||
private $type;
|
||||
/** @var float */
|
||||
private $frames;
|
||||
|
||||
public function __construct(SkinImage $image, int $type, float $frames){
|
||||
$this->image = $image;
|
||||
$this->type = $type;
|
||||
$this->frames = $frames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image of the animation.
|
||||
*
|
||||
* @return SkinImage
|
||||
*/
|
||||
public function getImage() : SkinImage{
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of animation you are applying.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType() : int{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The total amount of frames in an animation.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getFrames() : float{
|
||||
return $this->frames;
|
||||
}
|
||||
}
|
67
src/pocketmine/network/mcpe/protocol/types/SkinImage.php
Normal file
67
src/pocketmine/network/mcpe/protocol/types/SkinImage.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?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;
|
||||
|
||||
class SkinImage{
|
||||
|
||||
/** @var int */
|
||||
private $height;
|
||||
/** @var int */
|
||||
private $width;
|
||||
/** @var string */
|
||||
private $data;
|
||||
|
||||
public function __construct(int $height, int $width, string $data){
|
||||
$this->height = $height;
|
||||
$this->width = $width;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public static function fromLegacy(string $data) : SkinImage{
|
||||
switch(strlen($data)){
|
||||
case 64 * 32 * 4:
|
||||
return new self(64, 32, $data);
|
||||
case 64 * 64 * 4:
|
||||
return new self(64, 64, $data);
|
||||
case 128 * 64 * 4:
|
||||
return new self(128, 64, $data);
|
||||
case 128 * 128 * 4:
|
||||
return new self(128, 128, $data);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Unknown size");
|
||||
}
|
||||
|
||||
public function getHeight() : int{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
public function getWidth() : int{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
public function getData() : string{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user