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