PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
ServerboundDiagnosticsPacket.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;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
20
22 public const NETWORK_ID = ProtocolInfo::SERVERBOUND_DIAGNOSTICS_PACKET;
23
24 private float $avgFps;
25 private float $avgServerSimTickTimeMS;
26 private float $avgClientSimTickTimeMS;
27 private float $avgBeginFrameTimeMS;
28 private float $avgInputTimeMS;
29 private float $avgRenderTimeMS;
30 private float $avgEndFrameTimeMS;
31 private float $avgRemainderTimePercent;
32 private float $avgUnaccountedTimePercent;
33
37 public static function create(
38 float $avgFps,
39 float $avgServerSimTickTimeMS,
40 float $avgClientSimTickTimeMS,
41 float $avgBeginFrameTimeMS,
42 float $avgInputTimeMS,
43 float $avgRenderTimeMS,
44 float $avgEndFrameTimeMS,
45 float $avgRemainderTimePercent,
46 float $avgUnaccountedTimePercent,
47 ) : self{
48 $result = new self;
49 $result->avgFps = $avgFps;
50 $result->avgServerSimTickTimeMS = $avgServerSimTickTimeMS;
51 $result->avgClientSimTickTimeMS = $avgClientSimTickTimeMS;
52 $result->avgBeginFrameTimeMS = $avgBeginFrameTimeMS;
53 $result->avgInputTimeMS = $avgInputTimeMS;
54 $result->avgRenderTimeMS = $avgRenderTimeMS;
55 $result->avgEndFrameTimeMS = $avgEndFrameTimeMS;
56 $result->avgRemainderTimePercent = $avgRemainderTimePercent;
57 $result->avgUnaccountedTimePercent = $avgUnaccountedTimePercent;
58 return $result;
59 }
60
61 public function getAvgFps() : float{ return $this->avgFps; }
62
63 public function getAvgServerSimTickTimeMS() : float{ return $this->avgServerSimTickTimeMS; }
64
65 public function getAvgClientSimTickTimeMS() : float{ return $this->avgClientSimTickTimeMS; }
66
67 public function getAvgBeginFrameTimeMS() : float{ return $this->avgBeginFrameTimeMS; }
68
69 public function getAvgInputTimeMS() : float{ return $this->avgInputTimeMS; }
70
71 public function getAvgRenderTimeMS() : float{ return $this->avgRenderTimeMS; }
72
73 public function getAvgEndFrameTimeMS() : float{ return $this->avgEndFrameTimeMS; }
74
75 public function getAvgRemainderTimePercent() : float{ return $this->avgRemainderTimePercent; }
76
77 public function getAvgUnaccountedTimePercent() : float{ return $this->avgUnaccountedTimePercent; }
78
79 protected function decodePayload(ByteBufferReader $in) : void{
80 $this->avgFps = LE::readFloat($in);
81 $this->avgServerSimTickTimeMS = LE::readFloat($in);
82 $this->avgClientSimTickTimeMS = LE::readFloat($in);
83 $this->avgBeginFrameTimeMS = LE::readFloat($in);
84 $this->avgInputTimeMS = LE::readFloat($in);
85 $this->avgRenderTimeMS = LE::readFloat($in);
86 $this->avgEndFrameTimeMS = LE::readFloat($in);
87 $this->avgRemainderTimePercent = LE::readFloat($in);
88 $this->avgUnaccountedTimePercent = LE::readFloat($in);
89 }
90
91 protected function encodePayload(ByteBufferWriter $out) : void{
92 LE::writeFloat($out, $this->avgFps);
93 LE::writeFloat($out, $this->avgServerSimTickTimeMS);
94 LE::writeFloat($out, $this->avgClientSimTickTimeMS);
95 LE::writeFloat($out, $this->avgBeginFrameTimeMS);
96 LE::writeFloat($out, $this->avgInputTimeMS);
97 LE::writeFloat($out, $this->avgRenderTimeMS);
98 LE::writeFloat($out, $this->avgEndFrameTimeMS);
99 LE::writeFloat($out, $this->avgRemainderTimePercent);
100 LE::writeFloat($out, $this->avgUnaccountedTimePercent);
101 }
102
103 public function handle(PacketHandlerInterface $handler) : bool{
104 return $handler->handleServerboundDiagnostics($this);
105 }
106}
static create(float $avgFps, float $avgServerSimTickTimeMS, float $avgClientSimTickTimeMS, float $avgBeginFrameTimeMS, float $avgInputTimeMS, float $avgRenderTimeMS, float $avgEndFrameTimeMS, float $avgRemainderTimePercent, float $avgUnaccountedTimePercent,)