protocol: fixup data type changes, closes #3072

This commit is contained in:
Dylan K. Taylor 2019-08-11 19:00:27 +01:00
parent d756500928
commit 807b860cfe
3 changed files with 11 additions and 22 deletions

View File

@ -23,8 +23,8 @@ declare(strict_types=1);
namespace pocketmine\entity; namespace pocketmine\entity;
use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use function assert; use function assert;
use function is_float; use function is_float;
use function is_int; use function is_int;
@ -140,25 +140,14 @@ class DataPropertyManager{
$this->setPropertyValue($key, Entity::DATA_TYPE_STRING, $value, $force); $this->setPropertyValue($key, Entity::DATA_TYPE_STRING, $value, $force);
} }
/** public function getCompoundTag(int $key) : ?CompoundTag{
* @param int $key $value = $this->getPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG);
* assert($value instanceof CompoundTag or $value === null);
* @return null|Item
*/
public function getItem(int $key) : ?Item{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_SLOT);
assert($value instanceof Item or $value === null);
return $value; return $value;
} }
/** public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{
* @param int $key $this->setPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG, $value, $force);
* @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);
} }
/** /**

View File

@ -102,7 +102,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_TYPE_INT = 2; public const DATA_TYPE_INT = 2;
public const DATA_TYPE_FLOAT = 3; public const DATA_TYPE_FLOAT = 3;
public const DATA_TYPE_STRING = 4; 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_POS = 6;
public const DATA_TYPE_LONG = 7; public const DATA_TYPE_LONG = 7;
public const DATA_TYPE_VECTOR3F = 8; public const DATA_TYPE_VECTOR3F = 8;

View File

@ -227,8 +227,8 @@ class NetworkBinaryStream extends BinaryStream{
case Entity::DATA_TYPE_STRING: case Entity::DATA_TYPE_STRING:
$value = $this->getString(); $value = $this->getString();
break; break;
case Entity::DATA_TYPE_SLOT: case Entity::DATA_TYPE_COMPOUND_TAG:
$value = $this->getSlot(); $value = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
break; break;
case Entity::DATA_TYPE_POS: case Entity::DATA_TYPE_POS:
$value = new Vector3(); $value = new Vector3();
@ -279,8 +279,8 @@ class NetworkBinaryStream extends BinaryStream{
case Entity::DATA_TYPE_STRING: case Entity::DATA_TYPE_STRING:
$this->putString($d[1]); $this->putString($d[1]);
break; break;
case Entity::DATA_TYPE_SLOT: case Entity::DATA_TYPE_COMPOUND_TAG:
$this->putSlot($d[1]); $this->put((new NetworkLittleEndianNBTStream())->write($d[1]));
break; break;
case Entity::DATA_TYPE_POS: case Entity::DATA_TYPE_POS:
$v = $d[1]; $v = $d[1];