[GH-ISSUE #5631] Server: hitting a boat, minecart, armor stand or cushion doesn't reset the attack strength (Player.onAttack) #1758

Closed
opened 2026-11-02 15:49:26 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @navinor on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5631

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

What happens

On a server (server thread, LAN, dedicated), a player's hit on a boat, a minecart, an armor stand or a cushion leaves the server's attack strength charged. Only the client's swing packet resets it (S::Punch in game/lan_actions.rs:1623-1627, ServerGamePacketListenerImpl.handlePunch).

Vanilla resets it inside the attack itself. Player.attack calls this.onAttack() (Player.java:948) for every entity that passes cannotAttack, before any damage, and Player.onAttack runs resetOnlyAttackStrengthTicker() (Player.java:1823-1830).

Horizon does this for some targets and not others (origin/main b8cf85f8c):

Target Resets on the hit
mobs, attack_mob yes (game.rs:10528)
ender dragon yes (dragon.rs:1294)
players, PvP yes (lan_pvp.rs:181)
deflected projectiles yes (deflect.rs)
spear yes (spear.rs)
boat, attack_boat no (boats.rs:1026)
minecart, attack_cart no (minecarts.rs:1597)
armor stand, attack_armor_stand no (armor_stands.rs:590)
cushion, attack_cushion no (cushions.rs:355)

Item frames and paintings are right to skip it: BlockAttachedEntity.skipAttackInteraction returns true after its own hurt, so Player.attack stops before onAttack.

Why it matters

A client that sends attacks without a swing packet after each one (a bot, a modified client, a harness) hits vehicles at full strength every time: the vehicle's damage comes from Player.attack's strength scale (0.2 + s^2 * 0.8), and the server never brings s back to 0. A vanilla client sends the swing right after the attack, so normal play mostly hides the gap, but the server shouldn't depend on it. It came up in the review of #5547 (the lan_e2e fix for #5526).

Fix

Run the reset (reset_attack_strength, the port of Player.onAttack) in attack_boat, attack_cart, attack_armor_stand (when the stand isn't skipped) and attack_cushion, after the strength scale is read and before the damage, in vanilla's order. Ideally one shared Player.attack prologue so new targets don't miss it.

Test: attack a boat twice in the same tick through the server path with no swing packet in between; the second hit should come in at the reset strength (0.2 of the damage for a fist), as vanilla's does.

Originally created by @navinor on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5631 > 🤖 Filed by navinor's AI agent (OpenCode, Claude Opus 5.5), not by navinor personally. ## What happens On a server (server thread, LAN, dedicated), a player's hit on a boat, a minecart, an armor stand or a cushion leaves the server's attack strength charged. Only the client's swing packet resets it (`S::Punch` in `game/lan_actions.rs:1623-1627`, `ServerGamePacketListenerImpl.handlePunch`). Vanilla resets it inside the attack itself. `Player.attack` calls `this.onAttack()` (Player.java:948) for every entity that passes `cannotAttack`, before any damage, and `Player.onAttack` runs `resetOnlyAttackStrengthTicker()` (Player.java:1823-1830). Horizon does this for some targets and not others (origin/main b8cf85f8c): | Target | Resets on the hit | |---|---| | mobs, `attack_mob` | yes (`game.rs:10528`) | | ender dragon | yes (`dragon.rs:1294`) | | players, PvP | yes (`lan_pvp.rs:181`) | | deflected projectiles | yes (`deflect.rs`) | | spear | yes (`spear.rs`) | | boat, `attack_boat` | no (`boats.rs:1026`) | | minecart, `attack_cart` | no (`minecarts.rs:1597`) | | armor stand, `attack_armor_stand` | no (`armor_stands.rs:590`) | | cushion, `attack_cushion` | no (`cushions.rs:355`) | Item frames and paintings are right to skip it: `BlockAttachedEntity.skipAttackInteraction` returns true after its own hurt, so `Player.attack` stops before `onAttack`. ## Why it matters A client that sends attacks without a swing packet after each one (a bot, a modified client, a harness) hits vehicles at full strength every time: the vehicle's damage comes from `Player.attack`'s strength scale (`0.2 + s^2 * 0.8`), and the server never brings `s` back to 0. A vanilla client sends the swing right after the attack, so normal play mostly hides the gap, but the server shouldn't depend on it. It came up in the review of #5547 (the lan_e2e fix for #5526). ## Fix Run the reset (`reset_attack_strength`, the port of `Player.onAttack`) in `attack_boat`, `attack_cart`, `attack_armor_stand` (when the stand isn't skipped) and `attack_cushion`, after the strength scale is read and before the damage, in vanilla's order. Ideally one shared `Player.attack` prologue so new targets don't miss it. Test: attack a boat twice in the same tick through the server path with no swing packet in between; the second hit should come in at the reset strength (0.2 of the damage for a fist), as vanilla's does.
Author
Owner

@kira-horizon[bot] commented on GitHub (Nov 1, 2026):

Claimed by Navinor on Discord (GitHub: navinor), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #5631).

<!-- gh-comment-id:6551618432 --> @kira-horizon[bot] commented on GitHub (Nov 1, 2026): Claimed by `Navinor` on Discord (GitHub: `navinor`), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #5631). <!-- kira:work -->
Author
Owner

@navinor commented on GitHub (Nov 1, 2026):

🤖 Agent: Correction to the table: cushions belong with item frames and paintings, not with the targets missing the reset. Cushion extends BlockAttachedEntity, whose skipAttackInteraction returns true once its own hurt lands, so Player.attack stops before onAttack. The fix covers boats, minecarts and armor stands.

<!-- gh-comment-id:6552032843 --> @navinor commented on GitHub (Nov 1, 2026): 🤖 Agent: Correction to the table: cushions belong with item frames and paintings, not with the targets missing the reset. `Cushion` extends `BlockAttachedEntity`, whose `skipAttackInteraction` returns true once its own hurt lands, so `Player.attack` stops before `onAttack`. The fix covers boats, minecarts and armor stands.
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#1758
No description provided.