PocketMine-MP 5.42.1 git-443151900a14fe9dc682cbf786fa441be1294fab
Loading...
Searching...
No Matches
LocatorBarWaypoint.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\types;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
22
27 public function __construct(
28 private int $updateFlag,
29 private ?bool $visible,
30 private ?WorldPosition $worldPosition,
31 private ?int $textureId,
32 private ?Color $color,
33 private ?bool $clientPositionAuthority,
34 private ?int $actorUniqueId,
35 ){}
36
37 public function getUpdateFlag() : int{ return $this->updateFlag; }
38
39 public function getVisible() : ?bool{ return $this->visible; }
40
41 public function getWorldPosition() : ?WorldPosition{ return $this->worldPosition; }
42
43 public function getTextureId() : ?int{ return $this->textureId; }
44
45 public function getColor() : ?Color{ return $this->color; }
46
47 public function getClientPositionAuthority() : ?bool{ return $this->clientPositionAuthority; }
48
49 public function getActorUniqueId() : ?int{ return $this->actorUniqueId; }
50
51 public static function read(ByteBufferReader $in) : self{
52 $updateFlag = LE::readUnsignedInt($in);
53 $visible = CommonTypes::readOptional($in, CommonTypes::getBool(...));
54 $worldPosition = CommonTypes::readOptional($in, WorldPosition::read(...));
55 $textureId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
56 $color = CommonTypes::readOptional($in, fn() => Color::fromARGB(LE::readUnsignedInt($in)));
57 $clientPositionAuthority = CommonTypes::readOptional($in, CommonTypes::getBool(...));
58 $actorUniqueId = CommonTypes::readOptional($in, CommonTypes::getActorUniqueId(...));
59
60 return new self(
61 $updateFlag,
62 $visible,
63 $worldPosition,
64 $textureId,
65 $color,
66 $clientPositionAuthority,
67 $actorUniqueId,
68 );
69 }
70
71 public function write(ByteBufferWriter $out) : void{
72 LE::writeUnsignedInt($out, $this->updateFlag);
73 CommonTypes::writeOptional($out, $this->visible, CommonTypes::putBool(...));
74 CommonTypes::writeOptional($out, $this->worldPosition, fn(ByteBufferWriter $out, WorldPosition $v) => $v->write($out));
75 CommonTypes::writeOptional($out, $this->textureId, LE::writeUnsignedInt(...));
76 CommonTypes::writeOptional($out, $this->color, fn(ByteBufferWriter $out, Color $v) => LE::writeUnsignedInt($out, $v->toARGB()));
77 CommonTypes::writeOptional($out, $this->clientPositionAuthority, CommonTypes::putBool(...));
78 CommonTypes::writeOptional($out, $this->actorUniqueId, CommonTypes::putActorUniqueId(...));
79 }
80}