13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol;
18use pocketmine\network\mcpe\protocol\types\hud\HudElement;
19use pocketmine\network\mcpe\protocol\types\hud\HudVisibility;
23 public const NETWORK_ID = ProtocolInfo::SET_HUD_PACKET;
26 private array $hudElements = [];
27 private HudVisibility $visibility;
33 public static function create(array $hudElements, HudVisibility $visibility) : self{
35 $result->hudElements = $hudElements;
36 $result->visibility = $visibility;
43 public function getVisibility() : HudVisibility{ return $this->visibility; }
46 $this->hudElements = [];
48 $this->hudElements[] = HudElement::fromPacket($in->
getByte());
50 $this->visibility = HudVisibility::fromPacket($in->
getByte());
54 $out->putUnsignedVarInt(count($this->hudElements));
55 foreach($this->hudElements as $element){
56 $out->putByte($element->value);
58 $out->putByte($this->visibility->value);
62 return $handler->handleSetHud($this);
decodePayload(PacketSerializer $in)
static create(array $hudElements, HudVisibility $visibility)
encodePayload(PacketSerializer $out)
handle(PacketHandlerInterface $handler)