mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +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{
|
class AddEntityPacket extends DataPacket{
|
||||||
const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||||
|
|
||||||
|
/** @var int|null */
|
||||||
public $entityUniqueId = null; //TODO
|
public $entityUniqueId = null; //TODO
|
||||||
|
/** @var int */
|
||||||
public $entityRuntimeId;
|
public $entityRuntimeId;
|
||||||
public $type;
|
public $type;
|
||||||
public $x;
|
public $x;
|
||||||
|
@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession;
|
|||||||
class AddItemEntityPacket extends DataPacket{
|
class AddItemEntityPacket extends DataPacket{
|
||||||
const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
|
const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
|
||||||
|
|
||||||
|
/** @var int|null */
|
||||||
public $entityUniqueId = null; //TODO
|
public $entityUniqueId = null; //TODO
|
||||||
|
/** @var int */
|
||||||
public $entityRuntimeId;
|
public $entityRuntimeId;
|
||||||
public $item;
|
public $item;
|
||||||
public $x;
|
public $x;
|
||||||
|
@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession;
|
|||||||
class AddPaintingPacket extends DataPacket{
|
class AddPaintingPacket extends DataPacket{
|
||||||
const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
||||||
|
|
||||||
|
/** @var int|null */
|
||||||
public $entityUniqueId = null; //TODO
|
public $entityUniqueId = null; //TODO
|
||||||
|
/** @var int */
|
||||||
public $entityRuntimeId;
|
public $entityRuntimeId;
|
||||||
public $x;
|
public $x;
|
||||||
public $y;
|
public $y;
|
||||||
|
@ -27,13 +27,18 @@ namespace pocketmine\network\mcpe\protocol;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
|
use pocketmine\utils\UUID;
|
||||||
|
|
||||||
class AddPlayerPacket extends DataPacket{
|
class AddPlayerPacket extends DataPacket{
|
||||||
const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET;
|
const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET;
|
||||||
|
|
||||||
|
/** @var UUID */
|
||||||
public $uuid;
|
public $uuid;
|
||||||
|
/** @var string */
|
||||||
public $username;
|
public $username;
|
||||||
|
/** @var int|null */
|
||||||
public $entityUniqueId = null; //TODO
|
public $entityUniqueId = null; //TODO
|
||||||
|
/** @var int */
|
||||||
public $entityRuntimeId;
|
public $entityRuntimeId;
|
||||||
public $x;
|
public $x;
|
||||||
public $y;
|
public $y;
|
||||||
|
@ -128,6 +128,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
|||||||
$this->putByte($decoration["xOffset"]);
|
$this->putByte($decoration["xOffset"]);
|
||||||
$this->putByte($decoration["yOffset"]);
|
$this->putByte($decoration["yOffset"]);
|
||||||
$this->putString($decoration["label"]);
|
$this->putString($decoration["label"]);
|
||||||
|
assert($decoration["color"] instanceof Color);
|
||||||
$this->putLInt($decoration["color"]->toARGB());
|
$this->putLInt($decoration["color"]->toARGB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,41 +254,41 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and returns an EntityUniqueID
|
* Reads and returns an EntityUniqueID
|
||||||
* @return int|string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getEntityUniqueId(){
|
public function getEntityUniqueId() : int{
|
||||||
return $this->getVarLong();
|
return $this->getVarLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an EntityUniqueID
|
* Writes an EntityUniqueID
|
||||||
* @param int|string $eid
|
* @param int $eid
|
||||||
*/
|
*/
|
||||||
public function putEntityUniqueId($eid){
|
public function putEntityUniqueId(int $eid){
|
||||||
$this->putVarLong($eid);
|
$this->putVarLong($eid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and returns an EntityRuntimeID
|
* Reads and returns an EntityRuntimeID
|
||||||
* @return int|string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getEntityRuntimeId(){
|
public function getEntityRuntimeId() : int{
|
||||||
return $this->getUnsignedVarLong();
|
return $this->getUnsignedVarLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an EntityUniqueID
|
* Writes an EntityUniqueID
|
||||||
* @param int|string $eid
|
* @param int $eid
|
||||||
*/
|
*/
|
||||||
public function putEntityRuntimeId($eid){
|
public function putEntityRuntimeId(int $eid){
|
||||||
$this->putUnsignedVarLong($eid);
|
$this->putUnsignedVarLong($eid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an block position with unsigned Y coordinate.
|
* Reads an block position with unsigned Y coordinate.
|
||||||
* @param int $x
|
* @param int &$x
|
||||||
* @param int $y 0-255
|
* @param int &$y
|
||||||
* @param int $z
|
* @param int &$z
|
||||||
*/
|
*/
|
||||||
public function getBlockPosition(&$x, &$y, &$z){
|
public function getBlockPosition(&$x, &$y, &$z){
|
||||||
$x = $this->getVarInt();
|
$x = $this->getVarInt();
|
||||||
@ -298,11 +298,11 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a block position with unsigned Y coordinate.
|
* Writes a block position with unsigned Y coordinate.
|
||||||
* @param int &$x
|
* @param int $x
|
||||||
* @param int &$y
|
* @param int $y
|
||||||
* @param int &$z
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
public function putBlockPosition($x, $y, $z){
|
public function putBlockPosition(int $x, int $y, int $z){
|
||||||
$this->putVarInt($x);
|
$this->putVarInt($x);
|
||||||
$this->putUnsignedVarInt($y);
|
$this->putUnsignedVarInt($y);
|
||||||
$this->putVarInt($z);
|
$this->putVarInt($z);
|
||||||
@ -326,7 +326,7 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
* @param int $y
|
* @param int $y
|
||||||
* @param int $z
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
public function putSignedBlockPosition($x, $y, $z){
|
public function putSignedBlockPosition(int $x, int $y, int $z){
|
||||||
$this->putVarInt($x);
|
$this->putVarInt($x);
|
||||||
$this->putVarInt($y);
|
$this->putVarInt($y);
|
||||||
$this->putVarInt($z);
|
$this->putVarInt($z);
|
||||||
@ -350,7 +350,7 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
* @param float $y
|
* @param float $y
|
||||||
* @param float $z
|
* @param float $z
|
||||||
*/
|
*/
|
||||||
public function putVector3f($x, $y, $z){
|
public function putVector3f(float $x, float $y, float $z){
|
||||||
$this->putLFloat($x);
|
$this->putLFloat($x);
|
||||||
$this->putLFloat($y);
|
$this->putLFloat($y);
|
||||||
$this->putLFloat($z);
|
$this->putLFloat($z);
|
||||||
|
@ -382,12 +382,11 @@ class Binary{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an 8-byte integer.
|
* Reads an 8-byte integer.
|
||||||
* Note that this method will return a string on 32-bit PHP.
|
|
||||||
*
|
*
|
||||||
* @param string $x
|
* @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);
|
self::checkLength($x, 8);
|
||||||
$int = unpack("N*", $x);
|
$int = unpack("N*", $x);
|
||||||
return ($int[1] << 32) | $int[2];
|
return ($int[1] << 32) | $int[2];
|
||||||
@ -396,10 +395,10 @@ class Binary{
|
|||||||
/**
|
/**
|
||||||
* Writes an 8-byte integer.
|
* Writes an 8-byte integer.
|
||||||
*
|
*
|
||||||
* @param int|string $value
|
* @param int $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function writeLong($value) : string{
|
public static function writeLong(int $value) : string{
|
||||||
return pack("NN", $value >> 32, $value & 0xFFFFFFFF);
|
return pack("NN", $value >> 32, $value & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,19 +406,19 @@ class Binary{
|
|||||||
* Reads an 8-byte little-endian integer.
|
* Reads an 8-byte little-endian integer.
|
||||||
*
|
*
|
||||||
* @param string $str
|
* @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));
|
return self::readLong(strrev($str));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an 8-byte little-endian integer.
|
* Writes an 8-byte little-endian integer.
|
||||||
*
|
*
|
||||||
* @param int|string $value
|
* @param int $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function writeLLong($value) : string{
|
public static function writeLLong(int $value) : string{
|
||||||
return strrev(self::writeLong($value));
|
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));
|
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);
|
$this->buffer .= Binary::writeLong($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getLLong(){
|
public function getLLong() : int{
|
||||||
return Binary::readLLong($this->get(8));
|
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);
|
$this->buffer .= Binary::writeLLong($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,33 +337,33 @@ class BinaryStream{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 64-bit variable-length integer from the buffer and returns it.
|
* 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);
|
return Binary::readUnsignedVarLong($this->buffer, $this->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 64-bit variable-length integer to the end of the buffer.
|
* 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);
|
$this->buffer .= Binary::writeUnsignedVarLong($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 64-bit zigzag-encoded variable-length integer from the buffer and returns it.
|
* 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);
|
return Binary::readVarLong($this->buffer, $this->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 64-bit zigzag-encoded variable-length integer to the end of the buffer.
|
* 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);
|
$this->buffer .= Binary::writeVarLong($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user