mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
more typehints, removed more 32-bit leftovers
This commit is contained in:
parent
22d148a59d
commit
c0377fc63a
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user