PocketMine-MP 5.42.1 git-443151900a14fe9dc682cbf786fa441be1294fab
Loading...
Searching...
No Matches
SyncWorldClockStateData.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\VarInt;
21
26 public function __construct(
27 private int $clockId,
28 private int $time,
29 private bool $paused
30 ){}
31
32 public function getClockId() : int{ return $this->clockId; }
33
34 public function getTime() : int{ return $this->time; }
35
36 public function isPaused() : bool{ return $this->paused; }
37
38 public static function read(ByteBufferReader $in) : self{
39 $clockId = VarInt::readUnsignedLong($in);
40 $time = VarInt::readSignedInt($in);
41 $paused = CommonTypes::getBool($in);
42
43 return new self(
44 $clockId,
45 $time,
46 $paused
47 );
48 }
49
50 public function write(ByteBufferWriter $out) : void{
51 VarInt::writeUnsignedLong($out, $this->clockId);
52 VarInt::writeSignedInt($out, $this->time);
53 CommonTypes::putBool($out, $this->paused);
54 }
55}