Skip to main content

steel_protocol/packets/game/
c_ticking_state.rs

1use steel_macros::{ClientPacket, WriteTo};
2use steel_registry::packets::play::C_TICKING_STATE;
3
4/// Packet sent to clients to inform them of the current tick rate and frozen state.
5/// This allows clients to adjust their local tick rate manager for smoother gameplay.
6#[derive(WriteTo, ClientPacket, Clone, Debug)]
7#[packet_id(Play = C_TICKING_STATE)]
8pub struct CTickingState {
9    /// The current tick rate (ticks per second).
10    pub tick_rate: f32,
11    /// Whether the server is currently frozen.
12    pub is_frozen: bool,
13}
14
15impl CTickingState {
16    /// Creates a new ticking state packet.
17    #[must_use]
18    pub const fn new(tick_rate: f32, is_frozen: bool) -> Self {
19        Self {
20            tick_rate,
21            is_frozen,
22        }
23    }
24}