Skip to content

Commit

Permalink
added missing packet PingResponsePacket
Browse files Browse the repository at this point in the history
  • Loading branch information
Klotzi111 committed Aug 21, 2024
1 parent dfdfecc commit 8e188b1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using MineSharp.Core.Serialization;
using MineSharp.Data;
using MineSharp.Data.Protocol;

namespace MineSharp.Protocol.Packets.Clientbound.Play;

/// <summary>
/// Ping response packet
/// </summary>
/// <param name="Payload">The payload, should be the same as sent by the client</param>
public sealed record PingResponsePacket(long Payload) : IPacket
{
/// <inheritdoc />
public PacketType Type => StaticType;
/// <inheritdoc />
public static PacketType StaticType => PacketType.CB_Play_PingResponse;

/// <inheritdoc/>
public void Write(PacketBuffer buffer, MinecraftData version)
{
buffer.WriteLong(Payload);
}

/// <inheritdoc/>
public static IPacket Read(PacketBuffer buffer, MinecraftData version)
{
var payload = buffer.ReadLong();

return new PingResponsePacket(payload);
}
}
5 changes: 4 additions & 1 deletion Components/MineSharp.Protocol/Packets/PacketPalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +110,7 @@ void RegisterPacket<TPacket>()
// Status
// CB
RegisterPacket<StatusResponsePacket>();
RegisterPacket<PingResponsePacket>();
RegisterPacket<CBStatusPingResponsePacket>();

// SB
RegisterPacket<StatusRequestPacket>();
Expand Down Expand Up @@ -256,6 +258,7 @@ void RegisterPacket<TPacket>()
RegisterPacket<ExplosionPacket>();
RegisterPacket<LinkEntitiesPacket>();
RegisterPacket<SetContainerPropertyPacket>();
RegisterPacket<CBPlayPingResponsePacket>();

// SB
RegisterPacket<SBKeepAlivePacket>();
Expand Down

0 comments on commit 8e188b1

Please sign in to comment.