PocketMine-MP 5.15.1 git-08c6e63aac45a450fe3b437616ee8aa2500e04e2
MoveActorAbsolutePacket.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
19
21 public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_ABSOLUTE_PACKET;
22
23 public const FLAG_GROUND = 0x01;
24 public const FLAG_TELEPORT = 0x02;
25 public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x04;
26
27 public int $actorRuntimeId;
28 public Vector3 $position;
29 public float $pitch;
30 public float $yaw;
31 public float $headYaw; //always zero for non-mobs
32 public int $flags = 0;
33
37 public static function create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags) : self{
38 $result = new self;
39 $result->actorRuntimeId = $actorRuntimeId;
40 $result->position = $position;
41 $result->pitch = $pitch;
42 $result->yaw = $yaw;
43 $result->headYaw = $headYaw;
44 $result->flags = $flags;
45 return $result;
46 }
47
48 protected function decodePayload(PacketSerializer $in) : void{
49 $this->actorRuntimeId = $in->getActorRuntimeId();
50 $this->flags = $in->getByte();
51 $this->position = $in->getVector3();
52 $this->pitch = $in->getRotationByte();
53 $this->yaw = $in->getRotationByte();
54 $this->headYaw = $in->getRotationByte();
55 }
56
57 protected function encodePayload(PacketSerializer $out) : void{
58 $out->putActorRuntimeId($this->actorRuntimeId);
59 $out->putByte($this->flags);
60 $out->putVector3($this->position);
61 $out->putRotationByte($this->pitch);
62 $out->putRotationByte($this->yaw);
63 $out->putRotationByte($this->headYaw);
64 }
65
66 public function handle(PacketHandlerInterface $handler) : bool{
67 return $handler->handleMoveActorAbsolute($this);
68 }
69}
static create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags)