From 8e188b165d02f217ca24f3f80ae709f1589d0344 Mon Sep 17 00:00:00 2001 From: Klotzi111 Date: Wed, 21 Aug 2024 03:46:58 +0200 Subject: [PATCH] added missing packet PingResponsePacket --- .../Clientbound/Play/PingResponsePacket.cs | 31 +++++++++++++++++++ .../Packets/PacketPalette.cs | 5 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Components/MineSharp.Protocol/Packets/Clientbound/Play/PingResponsePacket.cs diff --git a/Components/MineSharp.Protocol/Packets/Clientbound/Play/PingResponsePacket.cs b/Components/MineSharp.Protocol/Packets/Clientbound/Play/PingResponsePacket.cs new file mode 100644 index 0000000..f337cac --- /dev/null +++ b/Components/MineSharp.Protocol/Packets/Clientbound/Play/PingResponsePacket.cs @@ -0,0 +1,31 @@ +using MineSharp.Core.Serialization; +using MineSharp.Data; +using MineSharp.Data.Protocol; + +namespace MineSharp.Protocol.Packets.Clientbound.Play; + +/// +/// Ping response packet +/// +/// The payload, should be the same as sent by the client +public sealed record PingResponsePacket(long Payload) : IPacket +{ + /// + public PacketType Type => StaticType; + /// + public static PacketType StaticType => PacketType.CB_Play_PingResponse; + + /// + public void Write(PacketBuffer buffer, MinecraftData version) + { + buffer.WriteLong(Payload); + } + + /// + public static IPacket Read(PacketBuffer buffer, MinecraftData version) + { + var payload = buffer.ReadLong(); + + return new PingResponsePacket(payload); + } +} diff --git a/Components/MineSharp.Protocol/Packets/PacketPalette.cs b/Components/MineSharp.Protocol/Packets/PacketPalette.cs index 03badc3..5729e6e 100644 --- a/Components/MineSharp.Protocol/Packets/PacketPalette.cs +++ b/Components/MineSharp.Protocol/Packets/PacketPalette.cs @@ -23,11 +23,13 @@ using CBPlayAddResourcePackPacket = MineSharp.Protocol.Packets.Clientbound.Play.AddResourcePackPacket; using CBPlayChangeDifficultyPacket = MineSharp.Protocol.Packets.Clientbound.Play.ChangeDifficultyPacket; using CBPlayMoveVehiclePacket = MineSharp.Protocol.Packets.Clientbound.Play.MoveVehiclePacket; +using CBPlayPingResponsePacket = MineSharp.Protocol.Packets.Clientbound.Play.PingResponsePacket; using CBPlayPlayerAbilitiesPacket = MineSharp.Protocol.Packets.Clientbound.Play.PlayerAbilitiesPacket; using CBPlayPluginMessagePacket = MineSharp.Protocol.Packets.Clientbound.Play.PluginMessagePacket; using CBPlayRemoveResourcePackPacket = MineSharp.Protocol.Packets.Clientbound.Play.RemoveResourcePackPacket; using CBPlayUpdateTagsPacket = MineSharp.Protocol.Packets.Clientbound.Play.UpdateTagsPacket; using CBSetHeldItemPacket = MineSharp.Protocol.Packets.Clientbound.Play.SetHeldItemPacket; +using CBStatusPingResponsePacket = MineSharp.Protocol.Packets.Clientbound.Status.PingResponsePacket; using ConfClientInformationPacket = MineSharp.Protocol.Packets.Serverbound.Configuration.ClientInformationPacket; using ConfigurationDisconnectPacket = MineSharp.Protocol.Packets.Clientbound.Configuration.DisconnectPacket; using ConfPingPacket = MineSharp.Protocol.Packets.Clientbound.Configuration.PingPacket; @@ -108,7 +110,7 @@ void RegisterPacket() // Status // CB RegisterPacket(); - RegisterPacket(); + RegisterPacket(); // SB RegisterPacket(); @@ -256,6 +258,7 @@ void RegisterPacket() RegisterPacket(); RegisterPacket(); RegisterPacket(); + RegisterPacket(); // SB RegisterPacket();