From de286f236f9ce7feef916fa54f2abf058f506a7b Mon Sep 17 00:00:00 2001 From: leifiyoo Date: Tue, 27 Oct 2026 15:52:19 +0100 Subject: [PATCH] Count down Riptide's spin on a server's copy of a player The host runs a guest's trident release on its copy of the guest, which sets the spin for 20 ticks. The copy never ran the client's movement tick, so the count never went down: the copy stayed in the spin pose (eye 0.4), and every arrow or projectile the guest shot was spawned from the leg until something else reset it. LivingEntity.aiStep counts autoSpinAttackTicks down on the server too. Count it down in the guest's server tick, before updatePlayerPose. Co-Authored-By: Claude Haiku 5.5 --- crates/horizon-client/src/game/lan_actions.rs | 3 ++ crates/horizon-client/src/motion.rs | 40 +++++++++++++++++++ crates/horizon-client/src/pose.rs | 12 ++++++ 3 files changed, 55 insertions(+) diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index 738399811..56dbf6bf1 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -2330,6 +2330,9 @@ impl Game<'_> { let _ = w.tick_environment_damage(); let _ = w.apply_fire_contact(); let _ = w.server_hazards_tick(in_wall); + // LivingEntity.aiStep: a Riptide spin counts down on the server's + // copy too, or it would stay in the spin pose (eye 0.4) for good. + w.player.count_down_server_spin(); // Player.tick ends with updatePlayerPose: a swimmer, or a player // crawling under a block, takes the short box its moves are checked with. let _ = w.update_player_pose(); diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index 06e513c00..8986aa01e 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -3446,6 +3446,46 @@ mod tests { } } #[test] + fn a_server_copy_of_a_riptide_spin_counts_down_and_stands_again() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../.local/horizon-client") + .join(horizon_core::VANILLA_VERSION); + if !root.join("movement-properties.nbt").exists() { + return; + } + let assets = Assets::load(&root).unwrap(); + let render = assets.reload(&root).unwrap(); + let binding = crate::collisions::load(&root, assets.registry).unwrap(); + let resources = MotionResources::load(&root, &assets).unwrap(); + let mut scene = World::test_scene(&assets, &render, 2).unwrap(); + let mut player = PlayerMotion::new(&resources, Vec3::new(20.5, 10.0, 20.5)).unwrap(); + player.auto_spin_attack_ticks = 2; + player.auto_spin_attack_dmg = 8.0; + let mut w = MotionWorld { + entities: &[], + player: &mut player, + scene: &mut scene, + assets: &assets, + collision_binding: &binding, + resources: &resources, + }; + w.update_player_pose().unwrap(); + assert_eq!(w.player.pose, crate::pose::Pose::SpinAttack); + w.player.count_down_server_spin(); + w.update_player_pose().unwrap(); + assert_eq!(w.player.pose, crate::pose::Pose::SpinAttack); + assert_eq!(w.player.auto_spin_attack_dmg, 8.0); + w.player.count_down_server_spin(); + assert_eq!(w.player.auto_spin_attack_ticks, 0); + assert_eq!(w.player.auto_spin_attack_dmg, 0.0); + w.update_player_pose().unwrap(); + assert_eq!(w.player.pose, crate::pose::Pose::Standing); + assert_eq!(w.player.dimensions.eye_height, 1.62); + // Nothing to count once the spin is over. + w.player.count_down_server_spin(); + assert_eq!(w.player.auto_spin_attack_ticks, 0); + } + #[test] fn a_riptide_spin_lies_flat_and_ends_on_the_first_entity_it_touches() { let root = Path::new(env!("CARGO_MANIFEST_DIR")) .join("../../.local/horizon-client") diff --git a/crates/horizon-client/src/pose.rs b/crates/horizon-client/src/pose.rs index 2a01579f3..1bad4898d 100644 --- a/crates/horizon-client/src/pose.rs +++ b/crates/horizon-client/src/pose.rs @@ -78,6 +78,18 @@ impl Dimensions { } } impl PlayerMotion { + /// `LivingEntity.aiStep` counting down `autoSpinAttackTicks` for a + /// server's copy of a player, which runs no client tick: the spin ends + /// after its ticks and its damage goes with it, so the pose (and the eye + /// a bow or a trident is shot from) comes back to standing. + pub fn count_down_server_spin(&mut self) { + if self.auto_spin_attack_ticks > 0 { + self.auto_spin_attack_ticks -= 1; + if self.auto_spin_attack_ticks <= 0 { + self.auto_spin_attack_dmg = 0.0; + } + } + } pub fn dimensions_for_pose(&mut self, pose: Pose) -> Result { Ok(pose.dimensions(self.attribute("minecraft:scale")? as f32)) }