steel_protocol/packets/game/
c_update_attributes.rs1use steel_macros::{ClientPacket, WriteTo};
4use steel_registry::packets::play::C_UPDATE_ATTRIBUTES;
5use steel_utils::Identifier;
6
7pub use steel_registry::attribute::AttributeModifierOperation;
8
9#[derive(WriteTo, Clone, Debug)]
11pub struct AttributeModifierData {
12 pub id: Identifier,
14 pub amount: f64,
16 pub operation: AttributeModifierOperation,
18}
19
20#[derive(WriteTo, Clone, Debug)]
22pub struct AttributeSnapshot {
23 #[write(as = VarInt)]
25 pub attribute_id: i32,
26 pub base_value: f64,
28 #[write(as = Prefixed(VarInt))]
30 pub modifiers: Vec<AttributeModifierData>,
31}
32
33#[derive(ClientPacket, WriteTo, Clone, Debug)]
37#[packet_id(Play = C_UPDATE_ATTRIBUTES)]
38pub struct CUpdateAttributes {
39 #[write(as = VarInt)]
41 pub entity_id: i32,
42 #[write(as = Prefixed(VarInt))]
44 pub attributes: Vec<AttributeSnapshot>,
45}
46
47impl CUpdateAttributes {
48 #[must_use]
50 pub const fn new(entity_id: i32, attributes: Vec<AttributeSnapshot>) -> Self {
51 Self {
52 entity_id,
53 attributes,
54 }
55 }
56}