From 807b860cfe3744963d997e7935af5d5a96ea4268 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 11 Aug 2019 19:00:27 +0100 Subject: [PATCH] protocol: fixup data type changes, closes #3072 --- src/pocketmine/entity/DataPropertyManager.php | 23 +++++-------------- src/pocketmine/entity/Entity.php | 2 +- .../network/mcpe/NetworkBinaryStream.php | 8 +++---- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/pocketmine/entity/DataPropertyManager.php b/src/pocketmine/entity/DataPropertyManager.php index c8646132f..890ff3e2f 100644 --- a/src/pocketmine/entity/DataPropertyManager.php +++ b/src/pocketmine/entity/DataPropertyManager.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\entity; -use pocketmine\item\Item; use pocketmine\math\Vector3; +use pocketmine\nbt\tag\CompoundTag; use function assert; use function is_float; use function is_int; @@ -140,25 +140,14 @@ class DataPropertyManager{ $this->setPropertyValue($key, Entity::DATA_TYPE_STRING, $value, $force); } - /** - * @param int $key - * - * @return null|Item - */ - public function getItem(int $key) : ?Item{ - $value = $this->getPropertyValue($key, Entity::DATA_TYPE_SLOT); - assert($value instanceof Item or $value === null); - + public function getCompoundTag(int $key) : ?CompoundTag{ + $value = $this->getPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG); + assert($value instanceof CompoundTag or $value === null); return $value; } - /** - * @param int $key - * @param Item $value - * @param bool $force - */ - public function setItem(int $key, Item $value, bool $force = false) : void{ - $this->setPropertyValue($key, Entity::DATA_TYPE_SLOT, $value, $force); + public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{ + $this->setPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG, $value, $force); } /** diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index b464da92c..a2026f4ec 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -102,7 +102,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_TYPE_INT = 2; public const DATA_TYPE_FLOAT = 3; public const DATA_TYPE_STRING = 4; - public const DATA_TYPE_SLOT = 5; + public const DATA_TYPE_COMPOUND_TAG = 5; public const DATA_TYPE_POS = 6; public const DATA_TYPE_LONG = 7; public const DATA_TYPE_VECTOR3F = 8; diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index cf71dfaf1..eb2456703 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -227,8 +227,8 @@ class NetworkBinaryStream extends BinaryStream{ case Entity::DATA_TYPE_STRING: $value = $this->getString(); break; - case Entity::DATA_TYPE_SLOT: - $value = $this->getSlot(); + case Entity::DATA_TYPE_COMPOUND_TAG: + $value = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512); break; case Entity::DATA_TYPE_POS: $value = new Vector3(); @@ -279,8 +279,8 @@ class NetworkBinaryStream extends BinaryStream{ case Entity::DATA_TYPE_STRING: $this->putString($d[1]); break; - case Entity::DATA_TYPE_SLOT: - $this->putSlot($d[1]); + case Entity::DATA_TYPE_COMPOUND_TAG: + $this->put((new NetworkLittleEndianNBTStream())->write($d[1])); break; case Entity::DATA_TYPE_POS: $v = $d[1];