[PR #1105] [MERGED] Combat: attribute swapping (attack damage and speed from last tick's main hand) #3052

Closed
opened 2026-11-02 16:01:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1105
Author: @ludovic111
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: fix/attribute-swapping


📝 Commits (1)

  • c017393 Combat: attack damage and speed come from last tick's main hand (attribute swapping)

📊 Changes

5 files changed (+48 additions, -18 deletions)

View changed files

📝 crates/horizon-client/src/attack_strength.rs (+5 -1)
📝 crates/horizon-client/src/game.rs (+8 -9)
📝 crates/horizon-client/src/game/dragon.rs (+2 -4)
📝 crates/horizon-client/src/game/hand.rs (+12 -4)
📝 crates/horizon-client/src/game/lan_actions.rs (+21 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #505. Reported by Online5277: thanks!

What

Attribute swapping works: switching hotbar slots just before an attack hits with the previous item's attack damage and attack speed (charge) and the new item's enchantments and effects (a Wind Burst, Density or Breach mace, Fire Aspect, Knockback...).

Why

The player's ATTACK_DAMAGE and ATTACK_SPEED modifiers only change in LivingEntity.detectEquipmentUpdates, once per server tick, while Player.attack reads the weapon (getWeaponItem: enchantments, the mace's smash bonus, post-attack effects) at the attack. The swap and the attack packets arrive between two ticks, so the attack mixes the old item's attributes with the new item's enchantments. Horizon read everything from the item in hand at the attack.

Also from Player.tick: switching to a different item resets the attack strength. Only the HUD indicator's ticker did; the one damage uses never reset, so a swapped-in weapon kept the old one's full charge after the next tick.

How

  • Game::attack_item: the main hand's item at the last player tick (tick_hand, where Player.tick compares lastItemInMainHand). melee_damage, the attack-strength scale, the attack indicator and the dragon hit read their damage and speed from it.
  • AttackStrength::tick says when it reset, and the damage ticker resets with it.
  • LAN guests: the same per guest (GuestPlay::attack_item, updated in the guest's server tick).

Proof

Self-check on one integration commit holding the seven B4 branches (#1049 #1050 #1046 #1056 #505 #504 #1097), on origin/main caeffffb, on the Mac mini:

cargo fmt --all --check                                                   ok
set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings    exit 0
cargo test -p horizon-client -p horizon-world                             all passed, 0 failed (horizon-client lib 959, horizon-world lib 152, ...)

tools/parity.py --changed origin/main (selects 304 of 326 harnesses: the branches touch game.rs): running on the integration commit; the result follows in a comment.

Needs Ludovic

Nothing.

🤖 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/1105 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/attribute-swapping` --- ### 📝 Commits (1) - [`c017393`](https://github.com/horizon-rust/horizon/commit/c01739300a85f5b8c64778dfa1674502bd75cd33) Combat: attack damage and speed come from last tick's main hand (attribute swapping) ### 📊 Changes **5 files changed** (+48 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/attack_strength.rs` (+5 -1) 📝 `crates/horizon-client/src/game.rs` (+8 -9) 📝 `crates/horizon-client/src/game/dragon.rs` (+2 -4) 📝 `crates/horizon-client/src/game/hand.rs` (+12 -4) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+21 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #505. Reported by **Online5277**: thanks! ## What Attribute swapping works: switching hotbar slots just before an attack hits with the previous item's attack damage and attack speed (charge) and the new item's enchantments and effects (a Wind Burst, Density or Breach mace, Fire Aspect, Knockback...). ## Why The player's `ATTACK_DAMAGE` and `ATTACK_SPEED` modifiers only change in `LivingEntity.detectEquipmentUpdates`, once per server tick, while `Player.attack` reads the weapon (`getWeaponItem`: enchantments, the mace's smash bonus, post-attack effects) at the attack. The swap and the attack packets arrive between two ticks, so the attack mixes the old item's attributes with the new item's enchantments. Horizon read everything from the item in hand at the attack. Also from `Player.tick`: switching to a different item resets the attack strength. Only the HUD indicator's ticker did; the one damage uses never reset, so a swapped-in weapon kept the old one's full charge after the next tick. ## How - `Game::attack_item`: the main hand's item at the last player tick (`tick_hand`, where `Player.tick` compares `lastItemInMainHand`). `melee_damage`, the attack-strength scale, the attack indicator and the dragon hit read their damage and speed from it. - `AttackStrength::tick` says when it reset, and the damage ticker resets with it. - LAN guests: the same per guest (`GuestPlay::attack_item`, updated in the guest's server tick). ## Proof Self-check on one integration commit holding the seven B4 branches (#1049 #1050 #1046 #1056 #505 #504 #1097), on origin/main `caeffffb`, on the Mac mini: ``` cargo fmt --all --check ok set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings exit 0 cargo test -p horizon-client -p horizon-world all passed, 0 failed (horizon-client lib 959, horizon-world lib 152, ...) ``` `tools/parity.py --changed origin/main` (selects 304 of 326 harnesses: the branches touch `game.rs`): running on the integration commit; the result follows in a comment. ## Needs Ludovic Nothing. 🤖 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-02 16:01:07 +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#3052
No description provided.