[PR #2850] [MERGED] Fix sweep attacks never triggering, and make them hit nearby entities like vanilla #4654

Closed
opened 2026-11-03 05:06:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2850
Author: @deezhizyu
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/sweep-attack-2764


📝 Commits (8)

  • 3e0f4cf Sweep attacks hurt nearby mobs and show their arc
  • 49ce3e6 Sweep in vanilla's order and against everything it hits
  • 52c667f Sweep from stands, frames and dragon parts, and hurt other players
  • ee6b5bf Match Player.attack more closely: enchant bonus, magic crit, no frame sweep
  • 574f358 Hit boats and carts with the full attack damage, sweep victims in section order
  • 4f13db4 Share the sweep arc options and the crit burst helper
  • 8e36842 Merge upstream main into fix/sweep-attack-2764
  • db27568 Merge upstream main into fix/sweep-attack-2764

📊 Changes

9 files changed (+372 additions, -172 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+116 -119)
📝 crates/horizon-client/src/game/armor_stands.rs (+19 -0)
📝 crates/horizon-client/src/game/boats.rs (+6 -2)
📝 crates/horizon-client/src/game/combat.rs (+3 -0)
📝 crates/horizon-client/src/game/dragon.rs (+14 -15)
📝 crates/horizon-client/src/game/enchant_effects.rs (+7 -2)
📝 crates/horizon-client/src/game/lan_pvp.rs (+34 -31)
📝 crates/horizon-client/src/game/mace.rs (+167 -1)
📝 crates/horizon-client/src/game/minecarts.rs (+6 -2)

📄 Description

🤖 Opened by Andrii's AI agent (Claude), not by Andrii directly.

What and why

Fixes ludovic111/horizon#2764 (https://github.com/ludovic111/horizon/issues/2764): a fully charged sword attack never produced a sweep.

Root cause: Player.isSweepAttack needs horizontalDistanceSqr < (getSpeed() * 2.5)^2. The player's speed field is only refreshed by the local movement step, so for the player on the integrated server (and for a guest) it stayed 0 and the check always failed. The merged sweep code (#2143, #2129) and the open #2659 only run once a sweep triggers, so on main they never run in single player. sweep_attack_position now reads the movement speed attribute when it decides.

On top of the fix, this moves the sweep closer to Player.attack / doSweepAttack:

  • Sweep victims use the enchantment's sweeping_damage_ratio and getEnchantedDamage for each victim, in vanilla's order: sweep sound, victims, arc particle, then the crit/strong/weak sounds (the strong/weak sound is skipped on a crit or sweep).
  • Armor stands (not marker ones) are sweep victims and get knocked back, and an armor stand, boat, minecart, dragon part or player can start a sweep, so mobs next to them are swept too.
  • The arc position uses Mth.sin/cos like vanilla.
  • The main hit uses getEnchantedDamage on the real attack damage, a dragon part never gets a critical hit (it is not a LivingEntity), boats and minecarts take the full attack damage and are hurt before the sweep and sounds, and the enchanted-hit burst is also shown for them and for armor stands.
  • Item frames, paintings and cushions end the attack in skipAttackInteraction like vanilla, so no sweep or attack sound for them.

Not touched here: hurting other players with a sweep, which is #2659 by @kacpherek. I dropped my own version of that so we don't duplicate it. Both should work together.

Vanilla reference

Player.attack, Player.doSweepAttack, Player.isSweepAttack, Player.attackVisualEffects, BlockAttachedEntity.skipAttackInteraction, ArmorStand.hurtServer, read from the 26.3 jars with javap. Unit test covers the sweep base damage. No parity harness is included (see below).

Tested

Played in the game, on this branch merged with current main: with a diamond sword, Sweeping Edge III and Sharpness III at full charge the target took 9 and each swept mob took 8.25 (1 + 0.75 * 7 = 6.25, plus 2 from Sharpness); without enchantments swept mobs took 1. Armor stands and boats behave as expected, and the sweep arc and the sounds are there in the game.

Not implemented / known differences

Happy to do any of these here or in a follow-up if you want:

  • No Java-oracle parity harness for the sweep. The sweep maths lives in horizon-client while the harnesses reach horizon-world, so it needs moving some of it across plus a vanilla Player stub. Parity is checked against the bytecode and by hand for now.
  • Fire Aspect on armor stands is not modelled (Horizon has no burning state for stands).
  • Victim order: mobs and armor stands are swept in one list by chunk section then entity id (a stand-in for vanilla's add order); other players (#2659) are hurt afterwards, not interleaved.
  • Dragon parts (sweep from and onto them) are not tested in game.
  • The close-range boat punch bug (pigs in a boat can't be hit up close) is a separate issue and not touched.

Self-check

python tools/pr_ready.py --quick on Windows (before merging main): rustfmt and clippy pass; 3 horizon-client tests fail (crash::tests::stacks_start_at_the_panicking_frame, save::tests::session_lock_is_exclusive, win_screen::tests::the_screen_ends_once_everything_rolled_past) and Python tests report failures. They look Windows-related (file locks, paths) and I did not confirm them on a clean main. After the merge I ran clippy -D warnings and the sweep unit test (both pass). Parity was not run locally.

Maintainer edits are allowed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2850 **Author:** [@deezhizyu](https://github.com/deezhizyu) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sweep-attack-2764` --- ### 📝 Commits (8) - [`3e0f4cf`](https://github.com/horizon-rust/horizon/commit/3e0f4cf65349e60282fd2e1d05bcccffc9f87221) Sweep attacks hurt nearby mobs and show their arc - [`49ce3e6`](https://github.com/horizon-rust/horizon/commit/49ce3e6d5aa44be6b7e6fbbc0718cb0681df2954) Sweep in vanilla's order and against everything it hits - [`52c667f`](https://github.com/horizon-rust/horizon/commit/52c667f4230f5165a9dbcb4242cc5803dae8d315) Sweep from stands, frames and dragon parts, and hurt other players - [`ee6b5bf`](https://github.com/horizon-rust/horizon/commit/ee6b5bf58565e962fcdaeff15a3027ca0ebdcfbe) Match Player.attack more closely: enchant bonus, magic crit, no frame sweep - [`574f358`](https://github.com/horizon-rust/horizon/commit/574f3587ed0c78090b8abfa849a435af1ef815a0) Hit boats and carts with the full attack damage, sweep victims in section order - [`4f13db4`](https://github.com/horizon-rust/horizon/commit/4f13db42b04a203cd9854b13a02510c05f97f36d) Share the sweep arc options and the crit burst helper - [`8e36842`](https://github.com/horizon-rust/horizon/commit/8e36842891fd6e6c4601a6a83d9738a7fe93108d) Merge upstream main into fix/sweep-attack-2764 - [`db27568`](https://github.com/horizon-rust/horizon/commit/db275689295fd414880094105be6526817b1eacf) Merge upstream main into fix/sweep-attack-2764 ### 📊 Changes **9 files changed** (+372 additions, -172 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+116 -119) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+19 -0) 📝 `crates/horizon-client/src/game/boats.rs` (+6 -2) 📝 `crates/horizon-client/src/game/combat.rs` (+3 -0) 📝 `crates/horizon-client/src/game/dragon.rs` (+14 -15) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+7 -2) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+34 -31) 📝 `crates/horizon-client/src/game/mace.rs` (+167 -1) 📝 `crates/horizon-client/src/game/minecarts.rs` (+6 -2) </details> ### 📄 Description > 🤖 Opened by Andrii's AI agent (Claude), not by Andrii directly. ## What and why Fixes ludovic111/horizon#2764 (https://github.com/ludovic111/horizon/issues/2764): a fully charged sword attack never produced a sweep. **Root cause:** `Player.isSweepAttack` needs `horizontalDistanceSqr < (getSpeed() * 2.5)^2`. The player's `speed` field is only refreshed by the local movement step, so for the player on the integrated server (and for a guest) it stayed 0 and the check always failed. The merged sweep code (#2143, #2129) and the open #2659 only run once a sweep triggers, so on `main` they never run in single player. `sweep_attack_position` now reads the movement speed attribute when it decides. On top of the fix, this moves the sweep closer to `Player.attack` / `doSweepAttack`: - Sweep victims use the enchantment's `sweeping_damage_ratio` and `getEnchantedDamage` for each victim, in vanilla's order: sweep sound, victims, arc particle, then the crit/strong/weak sounds (the strong/weak sound is skipped on a crit or sweep). - Armor stands (not marker ones) are sweep victims and get knocked back, and an armor stand, boat, minecart, dragon part or player can start a sweep, so mobs next to them are swept too. - The arc position uses `Mth.sin/cos` like vanilla. - The main hit uses `getEnchantedDamage` on the real attack damage, a dragon part never gets a critical hit (it is not a `LivingEntity`), boats and minecarts take the full attack damage and are hurt before the sweep and sounds, and the enchanted-hit burst is also shown for them and for armor stands. - Item frames, paintings and cushions end the attack in `skipAttackInteraction` like vanilla, so no sweep or attack sound for them. Not touched here: hurting other **players** with a sweep, which is #2659 by @kacpherek. I dropped my own version of that so we don't duplicate it. Both should work together. ## Vanilla reference `Player.attack`, `Player.doSweepAttack`, `Player.isSweepAttack`, `Player.attackVisualEffects`, `BlockAttachedEntity.skipAttackInteraction`, `ArmorStand.hurtServer`, read from the 26.3 jars with `javap`. Unit test covers the sweep base damage. **No parity harness is included** (see below). ## Tested Played in the game, on this branch merged with current `main`: with a diamond sword, Sweeping Edge III and Sharpness III at full charge the target took 9 and each swept mob took 8.25 (`1 + 0.75 * 7 = 6.25`, plus 2 from Sharpness); without enchantments swept mobs took 1. Armor stands and boats behave as expected, and the sweep arc and the sounds are there in the game. ## Not implemented / known differences Happy to do any of these here or in a follow-up if you want: - **No Java-oracle parity harness for the sweep.** The sweep maths lives in `horizon-client` while the harnesses reach `horizon-world`, so it needs moving some of it across plus a vanilla `Player` stub. Parity is checked against the bytecode and by hand for now. - **Fire Aspect on armor stands** is not modelled (Horizon has no burning state for stands). - **Victim order:** mobs and armor stands are swept in one list by chunk section then entity id (a stand-in for vanilla's add order); other players (#2659) are hurt afterwards, not interleaved. - **Dragon parts** (sweep from and onto them) are not tested in game. - The close-range boat punch bug (pigs in a boat can't be hit up close) is a separate issue and not touched. ## Self-check `python tools/pr_ready.py --quick` on Windows (before merging `main`): rustfmt and clippy pass; 3 `horizon-client` tests fail (`crash::tests::stacks_start_at_the_panicking_frame`, `save::tests::session_lock_is_exclusive`, `win_screen::tests::the_screen_ends_once_everything_rolled_past`) and Python tests report failures. They look Windows-related (file locks, paths) and I did not confirm them on a clean `main`. After the merge I ran clippy `-D warnings` and the sweep unit test (both pass). Parity was not run locally. Maintainer edits are allowed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:06:57 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4654
No description provided.