steel_protocol/packets/game/c_damage_event.rs
1//! Clientbound damage event packet - tells the client an entity took damage.
2
3use glam::DVec3;
4use steel_macros::{ClientPacket, WriteTo};
5use steel_registry::packets::play::C_DAMAGE_EVENT;
6
7/// Sent when an entity takes damage. Used for hit animations and damage direction indicator.
8#[derive(ClientPacket, WriteTo, Clone, Debug)]
9#[packet_id(Play = C_DAMAGE_EVENT)]
10pub struct CDamageEvent {
11 #[write(as = VarInt)]
12 pub entity_id: i32,
13 /// The damage type ID in the `minecraft:damage_type` registry.
14 #[write(as = VarInt)]
15 pub source_type_id: i32,
16 /// The entity ID + 1 of the entity responsible for the damage, or 0 if none.
17 #[write(as = VarInt)]
18 pub source_cause_id: i32,
19 /// The entity ID + 1 of the entity that directly dealt the damage, or 0 if none.
20 #[write(as = VarInt)]
21 pub source_direct_id: i32,
22 /// Optional source position (e.g. for explosions).
23 /// Encoded as bool-prefixed via the `Option<T: WriteTo>` impl.
24 pub source_position: Option<DVec3>,
25}