mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Binary strict types (#969)
* Some Binary cleanup, type-hints and strict types yes, I know this is very crashy... that's good, because it highlights unexpected behaviour * added some default values
This commit is contained in:
@ -38,8 +38,8 @@ class AddEntityPacket extends DataPacket{
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
public $yaw;
|
||||
public $pitch;
|
||||
public $yaw = 0.0;
|
||||
public $pitch = 0.0;
|
||||
/** @var Attribute[] */
|
||||
public $attributes = [];
|
||||
public $metadata = [];
|
||||
|
@ -29,7 +29,7 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::AVAILABLE_COMMANDS_PACKET;
|
||||
|
||||
public $commands; //JSON-encoded command data
|
||||
public $unknown;
|
||||
public $unknown = "";
|
||||
|
||||
public function decode(){
|
||||
$this->commands = $this->getString();
|
||||
|
@ -31,10 +31,10 @@ class ContainerSetSlotPacket extends DataPacket{
|
||||
|
||||
public $windowid;
|
||||
public $slot;
|
||||
public $hotbarSlot;
|
||||
public $hotbarSlot = 0;
|
||||
/** @var Item */
|
||||
public $item;
|
||||
public $selectSlot;
|
||||
public $selectSlot = 0;
|
||||
|
||||
public function decode(){
|
||||
$this->windowid = $this->getByte();
|
||||
|
@ -19,6 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
@ -50,19 +50,19 @@ class EntityEventPacket extends DataPacket{
|
||||
|
||||
public $eid;
|
||||
public $event;
|
||||
public $unknown;
|
||||
public $data = 0;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityRuntimeId();
|
||||
$this->event = $this->getByte();
|
||||
$this->unknown = $this->getVarInt();
|
||||
$this->data = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityRuntimeId($this->eid);
|
||||
$this->putByte($this->event);
|
||||
$this->putVarInt($this->unknown);
|
||||
$this->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
@ -43,7 +43,7 @@ class MovePlayerPacket extends DataPacket{
|
||||
public $pitch;
|
||||
public $mode = self::MODE_NORMAL;
|
||||
public $onGround;
|
||||
public $ridingEid;
|
||||
public $ridingEid = 0;
|
||||
public $int1 = 0;
|
||||
public $int2 = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user