PocketMine-MP 5.43.2 git-a137a986d01d9af23452b2e741699a770c7ae112
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;
23
28 public function __construct(
29 private int $updateFlag,
30 private ?bool $visible,
31 private ?WorldPosition $worldPosition,
32 private ?string $texturePath,
33 private ?Vector2 $iconSize,
34 private ?Color $color,
35 private ?bool $clientPositionAuthority,
36 private ?int $actorUniqueId,
37 ){}
38
39 public function getUpdateFlag() : int{ return $this->updateFlag; }
40
41 public function getVisible() : ?bool{ return $this->visible; }
42
43 public function getWorldPosition() : ?WorldPosition{ return $this->worldPosition; }
44
45 public function getTexturePath() : ?string{ return $this->texturePath; }
46
47 public function getIconSize() : ?Vector2{ return $this->iconSize; }
48
49 public function getColor() : ?Color{ return $this->color; }
50
51 public function getClientPositionAuthority() : ?bool{ return $this->clientPositionAuthority; }
52
53 public function getActorUniqueId() : ?int{ return $this->actorUniqueId; }
54
55 public static function read(ByteBufferReader $in) : self{
56 $updateFlag = LE::readUnsignedInt($in);
57 $visible = CommonTypes::readOptional($in, CommonTypes::getBool(...));
58 $worldPosition = CommonTypes::readOptional($in, WorldPosition::read(...));
59 $texturePath = CommonTypes::readOptional($in, CommonTypes::getString(...));
60 $iconSize = CommonTypes::readOptional($in, CommonTypes::getVector2(...));
61 $color = CommonTypes::readOptional($in, fn() => Color::fromARGB(LE::readUnsignedInt($in)));
62 $clientPositionAuthority = CommonTypes::readOptional($in, CommonTypes::getBool(...));
63 $actorUniqueId = CommonTypes::readOptional($in, CommonTypes::getActorUniqueId(...));
64
65 return new self(
66 $updateFlag,
67 $visible,
68 $worldPosition,
69 $texturePath,
70 $iconSize,
71 $color,
72 $clientPositionAuthority,
73 $actorUniqueId,
74 );
75 }
76
77 public function write(ByteBufferWriter $out) : void{
78 LE::writeUnsignedInt($out, $this->updateFlag);
79 CommonTypes::writeOptional($out, $this->visible, CommonTypes::putBool(...));
80 CommonTypes::writeOptional($out, $this->worldPosition, fn(ByteBufferWriter $out, WorldPosition $v) => $v->write($out));
81 CommonTypes::writeOptional($out, $this->texturePath, CommonTypes::putString(...));
82 CommonTypes::writeOptional($out, $this->iconSize, CommonTypes::putVector2(...));
83 CommonTypes::writeOptional($out, $this->color, fn(ByteBufferWriter $out, Color $v) => LE::writeUnsignedInt($out, $v->toARGB()));
84 CommonTypes::writeOptional($out, $this->clientPositionAuthority, CommonTypes::putBool(...));
85 CommonTypes::writeOptional($out, $this->actorUniqueId, CommonTypes::putActorUniqueId(...));
86 }
87}