mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
protocol: fixup data type changes, closes #3072
This commit is contained in:
parent
d756500928
commit
807b860cfe
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user