Skip to content

Commit

Permalink
feat(protocol): added ServerboundDiagnosticPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
PMK744 committed Sep 15, 2024
1 parent fe84821 commit 1f4ebc1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/network/src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ import type {
HurtArmorPacket,
ShowCreditsPacket,
UpdateClientInputLocksPacket,
OnScreenTextureAnimationPacket
OnScreenTextureAnimationPacket,
ServerboundDiagnosticsPacket
} from "@serenityjs/protocol";
import type { NetworkPacketEvent } from "./packet-event";

Expand Down Expand Up @@ -273,6 +274,9 @@ interface NetworkEvents {
[Packet.UpdateClientInputLocks]: [
NetworkPacketEvent<UpdateClientInputLocksPacket>
];
[Packet.ServerboundDiagnosticPacket]: [
NetworkPacketEvent<ServerboundDiagnosticsPacket>
];
}

export { NetworkEvents };
3 changes: 2 additions & 1 deletion packages/protocol/src/enums/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ enum Packet {
SetHud = 0x1_34, // 308
AwardAchievement = 0x1_35, // 309
ClientboundCloseForm = 0x1_36, // 310
ServerboundLoadingScreenPacket = 0x1_38 // 312
ServerboundLoadingScreenPacket = 0x1_38, // 312
ServerboundDiagnosticPacket = 0x1_3b // 315
}

export { Packet };
2 changes: 1 addition & 1 deletion packages/protocol/src/proto/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ export * from "./block-event";
export * from "./entity-pick-request";
export * from "./hurt-armor";
export * from "./show-credits";

export * from "./update-client-input-locks";
export * from "./serverbound-diagnostics";
4 changes: 3 additions & 1 deletion packages/protocol/src/proto/data/packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import { HurtArmorPacket } from "./hurt-armor";
import { ShowCreditsPacket } from "./show-credits";
import { UpdateClientInputLocksPacket } from "./update-client-input-locks";
import { OnScreenTextureAnimationPacket } from "./on-screen-texture-animation";
import { ServerboundDiagnosticsPacket } from "./serverbound-diagnostics";

const Packets = {
[Packet.Login]: LoginPacket, // 1
Expand Down Expand Up @@ -225,7 +226,8 @@ const Packets = {
[Packet.SetHud]: SetHudPacket, // 308
[Packet.AwardAchievement]: AwardAchievementPacket, // 309
[Packet.ClientboundCloseForm]: ClientboundCloseFormPacket, // 310
[Packet.ServerboundLoadingScreenPacket]: ServerboundLoadingScreenPacketPacket // 312
[Packet.ServerboundLoadingScreenPacket]: ServerboundLoadingScreenPacketPacket, // 312
[Packet.ServerboundDiagnosticPacket]: ServerboundDiagnosticsPacket // 315
};

export { Packets };
21 changes: 21 additions & 0 deletions packages/protocol/src/proto/data/serverbound-diagnostics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Proto, Serialize } from "@serenityjs/raknet";
import { Endianness, Float32 } from "@serenityjs/binarystream";

import { Packet } from "../../enums";

import { DataPacket } from "./data-packet";

@Proto(Packet.ServerboundDiagnosticPacket)
class ServerboundDiagnosticsPacket extends DataPacket {
@Serialize(Float32, Endianness.Little) public fps!: number;
@Serialize(Float32, Endianness.Little) public serverSimTickTime!: number;
@Serialize(Float32, Endianness.Little) public clientSimTickTime!: number;
@Serialize(Float32, Endianness.Little) public beginFrameTime!: number;
@Serialize(Float32, Endianness.Little) public inputTime!: number;
@Serialize(Float32, Endianness.Little) public renderTime!: number;
@Serialize(Float32, Endianness.Little) public endFrameTime!: number;
@Serialize(Float32, Endianness.Little) public remainderTimePercent!: number;
@Serialize(Float32, Endianness.Little) public unaccountedTimePercent!: number;
}

export { ServerboundDiagnosticsPacket };

0 comments on commit 1f4ebc1

Please sign in to comment.