steel_core/player/game_mode/
swing.rs1use super::{InteractionHand, InteractionResult, LivingEntity, Player, SwingAnimation};
2
3impl Player {
4 pub fn swing(
6 &self,
7 hand: InteractionHand,
8 animation: SwingAnimation,
9 update_self: bool,
10 ) -> bool {
11 LivingEntity::swing(self, hand, animation, update_self)
12 }
13
14 pub fn swing_and_reset_attack_strength(
16 &self,
17 hand: InteractionHand,
18 animation: SwingAnimation,
19 update_self: bool,
20 ) {
21 if self.swing(hand, animation, update_self) {
22 self.reset_attack_strength_ticker();
23 }
24 }
25
26 pub(in crate::player) fn swing_after_interaction(
27 &self,
28 hand: InteractionHand,
29 animation: SwingAnimation,
30 result: InteractionResult,
31 ) {
32 if result.should_swing() {
33 self.swing_and_reset_attack_strength(
34 hand,
35 animation,
36 result == InteractionResult::SuccessServer,
37 );
38 }
39 }
40}