use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class MovePlayerPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET; const MODE_NORMAL = 0; const MODE_RESET = 1; const MODE_TELEPORT = 2; const MODE_PITCH = 3; //facepalm Mojang /** @var int */ public $entityRuntimeId; /** @var Vector3 */ public $position; /** @var float */ public $yaw; /** @var float */ public $bodyYaw; /** @var float */ public $pitch; /** @var int */ public $mode = self::MODE_NORMAL; /** @var bool */ public $onGround = false; //TODO /** @var int */ public $ridingEid = 0; /** @var int */ public $int1 = 0; /** @var int */ public $int2 = 0; protected function decodePayload(){ $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->position = $this->getVector3Obj(); $this->pitch = $this->getLFloat(); $this->yaw = $this->getLFloat(); $this->bodyYaw = $this->getLFloat(); $this->mode = $this->getByte(); $this->onGround = $this->getBool(); $this->ridingEid = $this->getEntityRuntimeId(); if($this->mode === MovePlayerPacket::MODE_TELEPORT){ $this->int1 = $this->getLInt(); $this->int2 = $this->getLInt(); } } protected function encodePayload(){ $this->putEntityRuntimeId($this->entityRuntimeId); $this->putVector3Obj($this->position); $this->putLFloat($this->pitch); $this->putLFloat($this->yaw); $this->putLFloat($this->bodyYaw); //TODO $this->putByte($this->mode); $this->putBool($this->onGround); $this->putEntityRuntimeId($this->ridingEid); if($this->mode === MovePlayerPacket::MODE_TELEPORT){ $this->putLInt($this->int1); $this->putLInt($this->int2); } } public function handle(NetworkSession $session) : bool{ return $session->handleMovePlayer($this); } }