[PR #5708] [MERGED] A hit on a boat, minecart or armor stand starts the attack strength again #6448

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5708
Author: @navinor
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/attack-strength-on-attack


📝 Commits (2)

  • 8967e6a A hit on a boat, minecart or armor stand starts the attack strength again
  • 536b846 Merge main into #5708

📊 Changes

8 files changed (+109 additions, -9 deletions)

View changed files

📝 crates/horizon-bots/src/main.rs (+41 -4)
📝 crates/horizon-client/src/game.rs (+1 -1)
📝 crates/horizon-client/src/game/armor_stands.rs (+3 -0)
📝 crates/horizon-client/src/game/boats.rs (+2 -0)
📝 crates/horizon-client/src/game/cushions.rs (+3 -1)
📝 crates/horizon-client/src/game/frames.rs (+6 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+2 -0)
📝 tools/server_packet_rules_e2e.py (+51 -3)

📄 Description

🤖 Opened by navinor's AI agent (OpenCode, Claude Opus 5.5), not by navinor personally.

What and why

Fixes #5631: on a server, hitting a boat, a minecart or an armor stand left the player's attack strength charged. Only the client's swing packet (S::Punch, handlePunch) started it again, so a client that attacked without swinging hit vehicles at full strength every time.

Vanilla resets it in the attack itself: Player.attack calls onAttack() (resetOnlyAttackStrengthTicker) for every entity that passes cannotAttack, before the damage, and uses the strength scale it read just before. Horizon's attack_mob, the dragon, PvP, deflected projectiles and the spear already did this. Now:

  • attack_boat, attack_cart and attack_armor_stand set attack_ticks to 0 after the hit's sounds and sweep, which read the scale. For the stand it's hurt or not: ArmorStand.skipAttackInteraction only asks mayInteract.
  • attack_frame does it for a fixed frame hit by a player who isn't in creative. ItemFrame.hurtServer refuses that hit (canHurtWhenFixed), so skipAttackInteraction is false and Player.attack goes on to onAttack.
  • attack_cushion does it for a player who may not build (adventure): Cushion.hurtServer refuses them, so the same holds. Its comment said the opposite and now matches.

They set the field directly, as attack_mob does. onAttack calls resetOnlyAttackStrengthTicker, which leaves the item swap ticker alone, while reset_attack_strength also resets hand_strength.

Frames, paintings and cushions whose hurt lands stay as they are: they are BlockAttachedEntitys, whose skipAttackInteraction returns true then, so Player.attack stops before onAttack.

The vehicle_attack_sounds doc said swing_arm resets the charge. It doesn't (swing_arm only swings), so the doc now names the hit.

Not in this PR (already missing before it):

  • A creative player's hit on a fixed frame breaks it in vanilla; Horizon still leaves it.
  • The attack.nodamage sound after a refused hit.
  • A guest's attack goes through look_at_entity and the guest's own pick, within the entity reach, instead of Player.attack on the packet's target. So a hit vanilla accepts up to 3 blocks beyond the interaction range does nothing.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

Player.attack (this.onAttack() after getAttackStrengthScale(0.5F)), Player.onAttack / resetOnlyAttackStrengthTicker, Player.cannotAttack, BlockAttachedEntity.skipAttackInteraction, ItemFrame.hurtServer / canHurtWhenFixed, VehicleEntity.hurtServer (damage × 10, destroyed past 40).

What checks it: tools/server_packet_rules_e2e.py, on a dedicated server. Two boats are summoned with fixed UUIDs, and a horizon-bot hits each one in a single round, without swinging:

  • The server takes one of a player's attacks a tick (lan/hub.rs stops reading at a move queued behind an attack), so after the first hit (10 damage) the others come a tick apart. With the reset, each is at strength 0.3, 2.72 damage. Without it, each is a full 10. The boat loses 1 a tick.
  • Boat Q takes 8 hits: about 22 with the reset, and it stands. Without the reset it breaks on the fifth (46).
  • Boat P takes 24 hits. Even with the reset it breaks, on the 19th, which shows the hits land.

Both boats get one round each, so the result doesn't depend on how fast the bots or the server run.

Runs on Windows. With the boat's reset removed and Q at 5 hits, twice: Q broke, and the harness failed with "boat Q should stand". Temporary logging showed each bot's hits on its own boat. With this branch: boat P, 24 hits in a row without a swing: 24 attacks, broke and boat Q, 8 hits in a row without a swing: 8 attacks, stands. The harness's other checks (border, carried item, game mode, beacon) pass as before.

The harness is run by hand (python3 tools/server_packet_rules_e2e.py --bin-dir target/fast); no CI job runs it.

For the test:

  • horizon-bots' --attack takes a UUID besides a player name (target_uuid, with a unit test), so a bot can hit an entity summoned with {UUID:[I;0,0,0,n]}. --attack-rounds N stops a bot after N rounds.
  • The harness turns Horizon's anticheat off in its server.toml. The anticheat drops attacks made without a swing, and the harness checks vanilla's rules.
  • It force-loads the boats' two chunks and summons the boats before the bots join, then checks that each UUID resolves.

Minecarts, armor stands, fixed frames and cushions get the same one line. The harness covers the boat only: a stand breaks on any second hit within 5 ticks whatever the damage, and fixed frames and refused cushions take no damage.

Other projects' code

None.

Self-check

pr_ready (tools/pr_ready.py --quick on Aaron, against origin/main at ad5aef0c5, 7 min 8 s)

Check Result
Scope ✅ 9 files, +114 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (1 min 22 s)
rustfmt ✅ (14 s)
clippy ✅ (9 s)
tests: horizon-bots, horizon-client ✅ 1601 passed (5 min 16 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

port_ledger.py check --base origin/main lists only gaps that were there before (VehicleEntity.hurtServer's DamageSource.getEntity and Entity.discard, ArmorStand.hurtServer's drift).

🤖 Generated with OpenCode


🔄 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/5708 **Author:** [@navinor](https://github.com/navinor) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/attack-strength-on-attack` --- ### 📝 Commits (2) - [`8967e6a`](https://github.com/horizon-rust/horizon/commit/8967e6abf18057e514f66a676479442fafc41731) A hit on a boat, minecart or armor stand starts the attack strength again - [`536b846`](https://github.com/horizon-rust/horizon/commit/536b8462a71c903af8bb6b61d24e96c8c0e9f597) Merge main into #5708 ### 📊 Changes **8 files changed** (+109 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-bots/src/main.rs` (+41 -4) 📝 `crates/horizon-client/src/game.rs` (+1 -1) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+3 -0) 📝 `crates/horizon-client/src/game/boats.rs` (+2 -0) 📝 `crates/horizon-client/src/game/cushions.rs` (+3 -1) 📝 `crates/horizon-client/src/game/frames.rs` (+6 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+2 -0) 📝 `tools/server_packet_rules_e2e.py` (+51 -3) </details> ### 📄 Description > 🤖 Opened by navinor's AI agent (OpenCode, Claude Opus 5.5), not by navinor personally. ## What and why Fixes #5631: on a server, hitting a boat, a minecart or an armor stand left the player's attack strength charged. Only the client's swing packet (`S::Punch`, `handlePunch`) started it again, so a client that attacked without swinging hit vehicles at full strength every time. Vanilla resets it in the attack itself: `Player.attack` calls `onAttack()` (`resetOnlyAttackStrengthTicker`) for every entity that passes `cannotAttack`, before the damage, and uses the strength scale it read just before. Horizon's `attack_mob`, the dragon, PvP, deflected projectiles and the spear already did this. Now: - `attack_boat`, `attack_cart` and `attack_armor_stand` set `attack_ticks` to 0 after the hit's sounds and sweep, which read the scale. For the stand it's hurt or not: `ArmorStand.skipAttackInteraction` only asks `mayInteract`. - `attack_frame` does it for a fixed frame hit by a player who isn't in creative. `ItemFrame.hurtServer` refuses that hit (`canHurtWhenFixed`), so `skipAttackInteraction` is false and `Player.attack` goes on to `onAttack`. - `attack_cushion` does it for a player who may not build (adventure): `Cushion.hurtServer` refuses them, so the same holds. Its comment said the opposite and now matches. They set the field directly, as `attack_mob` does. `onAttack` calls `resetOnlyAttackStrengthTicker`, which leaves the item swap ticker alone, while `reset_attack_strength` also resets `hand_strength`. Frames, paintings and cushions whose hurt lands stay as they are: they are `BlockAttachedEntity`s, whose `skipAttackInteraction` returns true then, so `Player.attack` stops before `onAttack`. The `vehicle_attack_sounds` doc said `swing_arm` resets the charge. It doesn't (`swing_arm` only swings), so the doc now names the hit. Not in this PR (already missing before it): - A creative player's hit on a fixed frame breaks it in vanilla; Horizon still leaves it. - The `attack.nodamage` sound after a refused hit. - A guest's attack goes through `look_at_entity` and the guest's own pick, within the entity reach, instead of `Player.attack` on the packet's target. So a hit vanilla accepts up to 3 blocks beyond the interaction range does nothing. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `Player.attack` (`this.onAttack()` after `getAttackStrengthScale(0.5F)`), `Player.onAttack` / `resetOnlyAttackStrengthTicker`, `Player.cannotAttack`, `BlockAttachedEntity.skipAttackInteraction`, `ItemFrame.hurtServer` / `canHurtWhenFixed`, `VehicleEntity.hurtServer` (damage × 10, destroyed past 40). What checks it: `tools/server_packet_rules_e2e.py`, on a dedicated server. Two boats are summoned with fixed UUIDs, and a horizon-bot hits each one in a single round, without swinging: - The server takes one of a player's attacks a tick (`lan/hub.rs` stops reading at a move queued behind an attack), so after the first hit (10 damage) the others come a tick apart. With the reset, each is at strength 0.3, 2.72 damage. Without it, each is a full 10. The boat loses 1 a tick. - Boat Q takes 8 hits: about 22 with the reset, and it stands. Without the reset it breaks on the fifth (46). - Boat P takes 24 hits. Even with the reset it breaks, on the 19th, which shows the hits land. Both boats get one round each, so the result doesn't depend on how fast the bots or the server run. Runs on Windows. With the boat's reset removed and Q at 5 hits, twice: Q broke, and the harness failed with "boat Q should stand". Temporary logging showed each bot's hits on its own boat. With this branch: `boat P, 24 hits in a row without a swing: 24 attacks, broke` and `boat Q, 8 hits in a row without a swing: 8 attacks, stands`. The harness's other checks (border, carried item, game mode, beacon) pass as before. The harness is run by hand (`python3 tools/server_packet_rules_e2e.py --bin-dir target/fast`); no CI job runs it. For the test: - horizon-bots' `--attack` takes a UUID besides a player name (`target_uuid`, with a unit test), so a bot can hit an entity summoned with `{UUID:[I;0,0,0,n]}`. `--attack-rounds N` stops a bot after N rounds. - The harness turns Horizon's anticheat off in its `server.toml`. The anticheat drops attacks made without a swing, and the harness checks vanilla's rules. - It force-loads the boats' two chunks and summons the boats before the bots join, then checks that each UUID resolves. Minecarts, armor stands, fixed frames and cushions get the same one line. The harness covers the boat only: a stand breaks on any second hit within 5 ticks whatever the damage, and fixed frames and refused cushions take no damage. ## Other projects' code None. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Aaron, against origin/main at ad5aef0c5, 7 min 8 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +114 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (1 min 22 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (9 s) | | tests: horizon-bots, horizon-client | ✅ 1601 passed (5 min 16 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `port_ledger.py check --base origin/main` lists only gaps that were there before (`VehicleEntity.hurtServer`'s `DamageSource.getEntity` and `Entity.discard`, `ArmorStand.hurtServer`'s drift). 🤖 Generated with [OpenCode](https://opencode.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:20:51 +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#6448
No description provided.