13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol;
21 public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_DELTA_PACKET;
23 public const FLAG_HAS_X = 0x01;
24 public const FLAG_HAS_Y = 0x02;
25 public const FLAG_HAS_Z = 0x04;
26 public const FLAG_HAS_PITCH = 0x08;
27 public const FLAG_HAS_YAW = 0x10;
28 public const FLAG_HAS_HEAD_YAW = 0x20;
29 public const FLAG_GROUND = 0x40;
30 public const FLAG_TELEPORT = 0x80;
31 public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x100;
33 public int $actorRuntimeId;
35 public float $xPos = 0;
36 public float $yPos = 0;
37 public float $zPos = 0;
38 public float $pitch = 0.0;
39 public float $yaw = 0.0;
40 public float $headYaw = 0.0;
46 if(($this->flags & $flag) !== 0){
56 if(($this->flags & $flag) !== 0){
63 $this->actorRuntimeId = $in->getActorRuntimeId();
65 $this->xPos = $this->maybeReadCoord(self::FLAG_HAS_X, $in);
66 $this->yPos = $this->maybeReadCoord(self::FLAG_HAS_Y, $in);
67 $this->zPos = $this->maybeReadCoord(self::FLAG_HAS_Z, $in);
68 $this->pitch = $this->maybeReadRotation(self::FLAG_HAS_PITCH, $in);
69 $this->yaw = $this->maybeReadRotation(self::FLAG_HAS_YAW, $in);
70 $this->headYaw = $this->maybeReadRotation(self::FLAG_HAS_HEAD_YAW, $in);
73 private function maybeWriteCoord(
int $flag,
float $val,
PacketSerializer $out) : void{
74 if(($this->flags & $flag) !== 0){
75 $out->putLFloat($val);
79 private function maybeWriteRotation(
int $flag,
float $val, PacketSerializer $out) : void{
80 if(($this->flags & $flag) !== 0){
81 $out->putRotationByte($val);
86 $out->putActorRuntimeId($this->actorRuntimeId);
87 $out->putLShort($this->flags);
88 $this->maybeWriteCoord(self::FLAG_HAS_X, $this->xPos, $out);
89 $this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yPos, $out);
90 $this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zPos, $out);
91 $this->maybeWriteRotation(self::FLAG_HAS_PITCH, $this->pitch, $out);
92 $this->maybeWriteRotation(self::FLAG_HAS_YAW, $this->yaw, $out);
93 $this->maybeWriteRotation(self::FLAG_HAS_HEAD_YAW, $this->headYaw, $out);
97 return $handler->handleMoveActorDelta($this);
decodePayload(PacketSerializer $in)
encodePayload(PacketSerializer $out)
handle(PacketHandlerInterface $handler)