diff --git a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php index d6b720ebd..679be54cf 100644 --- a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class AddEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET; + /** @var int|null */ public $entityUniqueId = null; //TODO + /** @var int */ public $entityRuntimeId; public $type; public $x; diff --git a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php index cd4246e3a..00c8cdd45 100644 --- a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class AddItemEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET; + /** @var int|null */ public $entityUniqueId = null; //TODO + /** @var int */ public $entityRuntimeId; public $item; public $x; diff --git a/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php b/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php index 47cf9e793..8f69d7e57 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class AddPaintingPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET; + /** @var int|null */ public $entityUniqueId = null; //TODO + /** @var int */ public $entityRuntimeId; public $x; public $y; diff --git a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php index 17fcd7221..e90f8dbb6 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php @@ -27,13 +27,18 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\utils\UUID; class AddPlayerPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET; + /** @var UUID */ public $uuid; + /** @var string */ public $username; + /** @var int|null */ public $entityUniqueId = null; //TODO + /** @var int */ public $entityRuntimeId; public $x; public $y; diff --git a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php index 174a7fc8c..217144b17 100644 --- a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php @@ -128,6 +128,7 @@ class ClientboundMapItemDataPacket extends DataPacket{ $this->putByte($decoration["xOffset"]); $this->putByte($decoration["yOffset"]); $this->putString($decoration["label"]); + assert($decoration["color"] instanceof Color); $this->putLInt($decoration["color"]->toARGB()); } } diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index 999781a39..091e332c1 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -254,41 +254,41 @@ abstract class DataPacket extends BinaryStream{ /** * Reads and returns an EntityUniqueID - * @return int|string + * @return int */ - public function getEntityUniqueId(){ + public function getEntityUniqueId() : int{ return $this->getVarLong(); } /** * Writes an EntityUniqueID - * @param int|string $eid + * @param int $eid */ - public function putEntityUniqueId($eid){ + public function putEntityUniqueId(int $eid){ $this->putVarLong($eid); } /** * Reads and returns an EntityRuntimeID - * @return int|string + * @return int */ - public function getEntityRuntimeId(){ + public function getEntityRuntimeId() : int{ return $this->getUnsignedVarLong(); } /** * Writes an EntityUniqueID - * @param int|string $eid + * @param int $eid */ - public function putEntityRuntimeId($eid){ + public function putEntityRuntimeId(int $eid){ $this->putUnsignedVarLong($eid); } /** * Reads an block position with unsigned Y coordinate. - * @param int $x - * @param int $y 0-255 - * @param int $z + * @param int &$x + * @param int &$y + * @param int &$z */ public function getBlockPosition(&$x, &$y, &$z){ $x = $this->getVarInt(); @@ -298,11 +298,11 @@ abstract class DataPacket extends BinaryStream{ /** * Writes a block position with unsigned Y coordinate. - * @param int &$x - * @param int &$y - * @param int &$z + * @param int $x + * @param int $y + * @param int $z */ - public function putBlockPosition($x, $y, $z){ + public function putBlockPosition(int $x, int $y, int $z){ $this->putVarInt($x); $this->putUnsignedVarInt($y); $this->putVarInt($z); @@ -326,7 +326,7 @@ abstract class DataPacket extends BinaryStream{ * @param int $y * @param int $z */ - public function putSignedBlockPosition($x, $y, $z){ + public function putSignedBlockPosition(int $x, int $y, int $z){ $this->putVarInt($x); $this->putVarInt($y); $this->putVarInt($z); @@ -350,7 +350,7 @@ abstract class DataPacket extends BinaryStream{ * @param float $y * @param float $z */ - public function putVector3f($x, $y, $z){ + public function putVector3f(float $x, float $y, float $z){ $this->putLFloat($x); $this->putLFloat($y); $this->putLFloat($z); diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index 386aaa3d5..8e609b1e9 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -382,12 +382,11 @@ class Binary{ /** * Reads an 8-byte integer. - * Note that this method will return a string on 32-bit PHP. * * @param string $x - * @return int|string + * @return int */ - public static function readLong(string $x){ + public static function readLong(string $x) : int{ self::checkLength($x, 8); $int = unpack("N*", $x); return ($int[1] << 32) | $int[2]; @@ -396,10 +395,10 @@ class Binary{ /** * Writes an 8-byte integer. * - * @param int|string $value + * @param int $value * @return string */ - public static function writeLong($value) : string{ + public static function writeLong(int $value) : string{ return pack("NN", $value >> 32, $value & 0xFFFFFFFF); } @@ -407,19 +406,19 @@ class Binary{ * Reads an 8-byte little-endian integer. * * @param string $str - * @return int|string + * @return int */ - public static function readLLong(string $str){ + public static function readLLong(string $str) : int{ return self::readLong(strrev($str)); } /** * Writes an 8-byte little-endian integer. * - * @param int|string $value + * @param int $value * @return string */ - public static function writeLLong($value) : string{ + public static function writeLLong(int $value) : string{ return strrev(self::writeLong($value)); } diff --git a/src/pocketmine/utils/BinaryStream.php b/src/pocketmine/utils/BinaryStream.php index 623ec6360..74e34a094 100644 --- a/src/pocketmine/utils/BinaryStream.php +++ b/src/pocketmine/utils/BinaryStream.php @@ -191,30 +191,30 @@ class BinaryStream{ /** - * @return int|string + * @return int */ - public function getLong(){ + public function getLong() : int{ return Binary::readLong($this->get(8)); } /** - * @param int|string $v + * @param int $v */ - public function putLong($v){ + public function putLong(int $v){ $this->buffer .= Binary::writeLong($v); } /** - * @return int|string + * @return int */ - public function getLLong(){ + public function getLLong() : int{ return Binary::readLLong($this->get(8)); } /** - * @param int|string $v + * @param int $v */ - public function putLLong($v){ + public function putLLong(int $v){ $this->buffer .= Binary::writeLLong($v); } @@ -337,33 +337,33 @@ class BinaryStream{ /** * Reads a 64-bit variable-length integer from the buffer and returns it. - * @return int|string int, or the string representation of an int64 on 32-bit platforms + * @return int */ - public function getUnsignedVarLong(){ + public function getUnsignedVarLong() : int{ return Binary::readUnsignedVarLong($this->buffer, $this->offset); } /** * Writes a 64-bit variable-length integer to the end of the buffer. - * @param int|string $v int, or the string representation of an int64 on 32-bit platforms + * @param int $v */ - public function putUnsignedVarLong($v){ + public function putUnsignedVarLong(int $v){ $this->buffer .= Binary::writeUnsignedVarLong($v); } /** * Reads a 64-bit zigzag-encoded variable-length integer from the buffer and returns it. - * @return int|string int, or the string representation of an int64 on 32-bit platforms + * @return int */ - public function getVarLong(){ + public function getVarLong() : int{ return Binary::readVarLong($this->buffer, $this->offset); } /** * Writes a 64-bit zigzag-encoded variable-length integer to the end of the buffer. - * @param int|string $v int, or the string representation of an int64 on 32-bit platforms + * @param int */ - public function putVarLong($v){ + public function putVarLong(int $v){ $this->buffer .= Binary::writeVarLong($v); }