Skip to main content

steel_protocol/packets/game/
c_award_stats.rs

1use std::io::Write;
2use steel_macros::ClientPacket;
3use steel_registry::packets::play::C_AWARD_STATS;
4use steel_registry::stat::Stat;
5use steel_utils::codec::VarInt;
6use steel_utils::serial::WriteTo;
7
8/// Clientbound packet that updates the client with the stats that have been
9/// marked dirty.
10#[derive(ClientPacket, Clone, Debug)]
11#[packet_id(Play = C_AWARD_STATS)]
12pub struct CAwardStats {
13    /// The dirty stats to send.
14    pub stats: Vec<(Stat, i32)>,
15}
16
17impl WriteTo for CAwardStats {
18    fn write(&self, writer: &mut impl Write) -> std::io::Result<()> {
19        VarInt(self.stats.len() as i32).write(writer)?;
20        for (stat, count) in &self.stats {
21            stat.write(writer)?;
22            VarInt(*count).write(writer)?;
23        }
24        Ok(())
25    }
26}