PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
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
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
22
24 public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_ABSOLUTE_PACKET;
25
26 public const FLAG_GROUND = 0x01;
27 public const FLAG_TELEPORT = 0x02;
28 public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x04;
29
30 public int $actorRuntimeId;
31 public Vector3 $position;
32 public float $pitch;
33 public float $yaw;
34 public float $headYaw; //always zero for non-mobs
35 public int $flags = 0;
36
40 public static function create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags) : self{
41 $result = new self;
42 $result->actorRuntimeId = $actorRuntimeId;
43 $result->position = $position;
44 $result->pitch = $pitch;
45 $result->yaw = $yaw;
46 $result->headYaw = $headYaw;
47 $result->flags = $flags;
48 return $result;
49 }
50
51 protected function decodePayload(ByteBufferReader $in) : void{
52 $this->actorRuntimeId = CommonTypes::getActorRuntimeId($in);
53 $this->flags = Byte::readUnsigned($in);
54 $this->position = CommonTypes::getVector3($in);
55 $this->pitch = CommonTypes::getRotationByte($in);
56 $this->yaw = CommonTypes::getRotationByte($in);
57 $this->headYaw = CommonTypes::getRotationByte($in);
58 }
59
60 protected function encodePayload(ByteBufferWriter $out) : void{
61 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
62 Byte::writeUnsigned($out, $this->flags);
63 CommonTypes::putVector3($out, $this->position);
64 CommonTypes::putRotationByte($out, $this->pitch);
65 CommonTypes::putRotationByte($out, $this->yaw);
66 CommonTypes::putRotationByte($out, $this->headYaw);
67 }
68
69 public function handle(PacketHandlerInterface $handler) : bool{
70 return $handler->handleMoveActorAbsolute($this);
71 }
72}
static create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags)