Pumpkin/pumpkin-protocol/src/java/client/play/ping_response.rs
Alexander Medvedev e0117ab559 perf: ditch serde because its slower
i rather trade performance and compile time over convenience
2026-07-19 18:07:37 +02:00

33 lines
879 B
Rust

use pumpkin_data::packet::clientbound::PLAY_PONG_RESPONSE;
use pumpkin_macros::java_packet;
use crate::ClientPacket;
use crate::ser::NetworkWriteExt;
use pumpkin_util::version::JavaMinecraftVersion;
/// Responds to a client-initiated ping request to synchronize game state.
#[java_packet(PLAY_PONG_RESPONSE)]
pub struct CPingResponse {
/// The unique identifier sent by the client in the initial Ping packet.
/// The server must return this exact value.
pub payload: i64,
}
impl CPingResponse {
#[must_use]
pub const fn new(payload: i64) -> Self {
Self { payload }
}
}
impl ClientPacket for CPingResponse {
fn write_packet_data(
&self,
mut write: impl std::io::Write,
_version: &JavaMinecraftVersion,
) -> Result<(), crate::ser::WritingError> {
write.write_i64_be(self.payload)?;
Ok(())
}
}