PocketMine-MP 5.39.2 git-7ad037014ecec1ddc7a9bba215beb03e659ea931
Loading...
Searching...
No Matches
DebugMarkerData.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
24final class DebugMarkerData{
25
26 public function __construct(
27 private string $text,
28 private Vector3 $position,
29 private Color $color,
30 private int $durationMillis
31 ){}
32
33 public function getText() : string{ return $this->text; }
34
35 public function getPosition() : Vector3{ return $this->position; }
36
37 public function getColor() : Color{ return $this->color; }
38
39 public function getDurationMillis() : int{ return $this->durationMillis; }
40
41 public static function read(ByteBufferReader $in) : self{
42 $text = CommonTypes::getString($in);
43 $position = CommonTypes::getVector3($in);
44 $color = Color::fromARGB(LE::readUnsignedInt($in));
45 $durationMillis = LE::readUnsignedLong($in);
46
47 return new self(
48 $text,
49 $position,
50 $color,
51 $durationMillis
52 );
53 }
54
55 public function write(ByteBufferWriter $out) : void{
56 CommonTypes::putString($out, $this->text);
57 CommonTypes::putVector3($out, $this->position);
58 LE::writeUnsignedInt($out, $this->color->toARGB());
59 LE::writeUnsignedLong($out, $this->durationMillis);
60 }
61}