steel_protocol/packets/game/
c_set_time.rs1use std::io::{Result, Write};
2use steel_macros::ClientPacket;
3use steel_registry::packets::play::C_SET_TIME;
4use steel_utils::codec::{VarInt, VarLong};
5use steel_utils::serial::WriteTo;
6
7#[derive(ClientPacket, Clone, Debug)]
8#[packet_id(Play = C_SET_TIME)]
9pub struct CSetTime {
10 pub game_time: i64,
11 pub clock_updates: Vec<(i32, i64, f32, f32)>,
13}
14
15impl WriteTo for CSetTime {
16 fn write(&self, writer: &mut impl Write) -> Result<()> {
17 self.game_time.write(writer)?;
18 VarInt(self.clock_updates.len() as i32).write(writer)?;
19 for &(clock_id, total_ticks, partial_tick, rate) in &self.clock_updates {
20 VarInt(clock_id).write(writer)?;
21 VarLong(total_ticks).write(writer)?;
22 partial_tick.write(writer)?;
23 rate.write(writer)?;
24 }
25 Ok(())
26 }
27}
28
29impl CSetTime {
30 #[must_use]
31 pub const fn new(game_time: i64, clock_updates: Vec<(i32, i64, f32, f32)>) -> Self {
32 Self {
33 game_time,
34 clock_updates,
35 }
36 }
37}