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:
Dylan K. Taylor
2017-06-03 09:39:45 +01:00
committed by GitHub
parent 8bb0e8d398
commit 22ba017965
8 changed files with 234 additions and 114 deletions

View File

@ -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 = [];

View File

@ -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();

View File

@ -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();

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>

View File

@ -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{

View File

@ -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;