PocketMine-MP 5.43.2 git-c9e7b3ab9bd2149f206392522e8eb7e9d8d68cfa
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 public const FLAG_FORCE_COMPLETION = 0x8;
30
31 public int $actorRuntimeId;
32 public Vector3 $position;
33 public float $pitch;
34 public float $yaw;
35 public float $headYaw; //always zero for non-mobs
36 public int $flags = 0;
37
41 public static function create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags) : self{
42 $result = new self;
43 $result->actorRuntimeId = $actorRuntimeId;
44 $result->position = $position;
45 $result->pitch = $pitch;
46 $result->yaw = $yaw;
47 $result->headYaw = $headYaw;
48 $result->flags = $flags;
49 return $result;
50 }
51
52 protected function decodePayload(ByteBufferReader $in) : void{
53 $this->actorRuntimeId = CommonTypes::getActorRuntimeId($in);
54 $this->flags = Byte::readUnsigned($in);
55 $this->position = CommonTypes::getVector3($in);
56 $this->pitch = CommonTypes::getRotationByte($in);
57 $this->yaw = CommonTypes::getRotationByte($in);
58 $this->headYaw = CommonTypes::getRotationByte($in);
59 }
60
61 protected function encodePayload(ByteBufferWriter $out) : void{
62 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
63 Byte::writeUnsigned($out, $this->flags);
64 CommonTypes::putVector3($out, $this->position);
65 CommonTypes::putRotationByte($out, $this->pitch);
66 CommonTypes::putRotationByte($out, $this->yaw);
67 CommonTypes::putRotationByte($out, $this->headYaw);
68 }
69
70 public function handle(PacketHandlerInterface $handler) : bool{
71 return $handler->handleMoveActorAbsolute($this);
72 }
73}
static create(int $actorRuntimeId, Vector3 $position, float $pitch, float $yaw, float $headYaw, int $flags)