steel_protocol/packets/game/
c_animate.rs1use steel_macros::{ClientPacket, WriteTo};
4use steel_registry::packets::play::C_ANIMATE;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, WriteTo)]
8#[repr(u8)]
9#[write(as = u8)]
10pub enum AnimateAction {
11 SwingMainHand = 0,
13 WakeUp = 2,
15 SwingOffHand = 3,
17 CriticalHit = 4,
19 MagicCriticalHit = 5,
21}
22
23#[derive(ClientPacket, WriteTo, Clone, Debug)]
25#[packet_id(Play = C_ANIMATE)]
26pub struct CAnimate {
27 #[write(as = VarInt)]
29 pub entity_id: i32,
30 pub action: AnimateAction,
32}
33
34impl CAnimate {
35 #[must_use]
37 pub const fn new(entity_id: i32, action: AnimateAction) -> Self {
38 Self { entity_id, action }
39 }
40
41 #[must_use]
43 pub const fn swing_main_hand(entity_id: i32) -> Self {
44 Self::new(entity_id, AnimateAction::SwingMainHand)
45 }
46
47 #[must_use]
49 pub const fn swing_off_hand(entity_id: i32) -> Self {
50 Self::new(entity_id, AnimateAction::SwingOffHand)
51 }
52
53 #[must_use]
55 pub const fn critical_hit(entity_id: i32) -> Self {
56 Self::new(entity_id, AnimateAction::CriticalHit)
57 }
58
59 #[must_use]
61 pub const fn magic_critical_hit(entity_id: i32) -> Self {
62 Self::new(entity_id, AnimateAction::MagicCriticalHit)
63 }
64}