mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Merge branch 'stable'
This commit is contained in:
@@ -23,40 +23,45 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types\entity;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\serializer\NetworkNbtSerializer;
|
||||
|
||||
final class ItemStackMetadataProperty implements MetadataProperty{
|
||||
/** @var Item */
|
||||
final class CompoundTagMetadataProperty implements MetadataProperty{
|
||||
/** @var CompoundTag */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param Item $value
|
||||
* @param CompoundTag $value
|
||||
*/
|
||||
public function __construct(Item $value){
|
||||
public function __construct(CompoundTag $value){
|
||||
$this->value = clone $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public function getValue() : Item{
|
||||
public function getValue() : CompoundTag{
|
||||
return clone $this->value;
|
||||
}
|
||||
|
||||
public static function id() : int{
|
||||
return EntityMetadataTypes::SLOT;
|
||||
return EntityMetadataTypes::COMPOUND_TAG;
|
||||
}
|
||||
|
||||
public function equals(MetadataProperty $other) : bool{
|
||||
return $other instanceof $this and $other->value->equalsExact($this->value);
|
||||
return $other instanceof $this and $other->value->equals($this->value);
|
||||
}
|
||||
|
||||
public static function read(NetworkBinaryStream $in) : self{
|
||||
return new self($in->getSlot());
|
||||
$offset = $in->getOffset();
|
||||
$result = new self((new NetworkNbtSerializer())->read($in->getBuffer(), $offset, 512)->getTag());
|
||||
$in->setOffset($offset);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function write(NetworkBinaryStream $out) : void{
|
||||
$out->putSlot($this->value);
|
||||
$out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->value)));
|
||||
}
|
||||
}
|
@@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types\entity;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use function get_class;
|
||||
|
||||
class EntityMetadataCollection{
|
||||
@@ -85,12 +85,12 @@ class EntityMetadataCollection{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
* @param Item $value
|
||||
* @param bool $force
|
||||
* @param int $key
|
||||
* @param CompoundTag $value
|
||||
* @param bool $force
|
||||
*/
|
||||
public function setItem(int $key, Item $value, bool $force = false) : void{
|
||||
$this->set($key, new ItemStackMetadataProperty($value), $force);
|
||||
public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{
|
||||
$this->set($key, new CompoundTagMetadataProperty($value), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -34,7 +34,7 @@ final class EntityMetadataTypes{
|
||||
public const INT = 2;
|
||||
public const FLOAT = 3;
|
||||
public const STRING = 4;
|
||||
public const SLOT = 5;
|
||||
public const COMPOUND_TAG = 5;
|
||||
public const POS = 6;
|
||||
public const LONG = 7;
|
||||
public const VECTOR3F = 8;
|
||||
|
@@ -42,7 +42,7 @@ use pocketmine\network\mcpe\protocol\types\entity\ByteMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\FloatMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\IntMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\ItemStackMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\CompoundTagMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\LongMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\ShortMetadataProperty;
|
||||
@@ -258,7 +258,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
case IntMetadataProperty::id(): return IntMetadataProperty::read($this);
|
||||
case FloatMetadataProperty::id(): return FloatMetadataProperty::read($this);
|
||||
case StringMetadataProperty::id(): return StringMetadataProperty::read($this);
|
||||
case ItemStackMetadataProperty::id(): return ItemStackMetadataProperty::read($this);
|
||||
case CompoundTagMetadataProperty::id(): return CompoundTagMetadataProperty::read($this);
|
||||
case BlockPosMetadataProperty::id(): return BlockPosMetadataProperty::read($this);
|
||||
case LongMetadataProperty::id(): return LongMetadataProperty::read($this);
|
||||
case Vec3MetadataProperty::id(): return Vec3MetadataProperty::read($this);
|
||||
|
Reference in New Issue
Block a user