[PR #5017] [MERGED] Melee damage reads the attack_damage attribute #6009

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5017
Author: @Username59138
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/melee-attack-damage-attribute


📝 Commits (1)

  • b8b6196 Melee damage reads the attack_damage attribute

📊 Changes

5 files changed (+14 additions, -19 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+2 -6)
📝 crates/horizon-client/src/game/enchant_effects.rs (+0 -8)
📝 crates/horizon-client/src/game/hand.rs (+10 -0)
📝 crates/horizon-client/src/game/mace.rs (+1 -2)
📝 crates/horizon-client/src/game/spear.rs (+1 -3)

📄 Description

What and why

Fixes #4191. /attribute @s minecraft:attack_damage base set 50 (or modifier add) changed the attribute but not a hit: melee_damage built the damage by hand as 1.0 + the held item's damage + Strength/Weakness and never read the attribute.

Vanilla's Player.attack takes the damage from getAttributeValue(ATTACK_DAMAGE) alone: the base 1.0, the weapon's modifiers and the effects' modifiers are all on the attribute. Since #4132 the main hand's modifiers reach Horizon's attribute map too, and the effects' already did (apply_effect_status), so the attack now reads the attribute the same way:

  • hand.rs: attack_damage(), the player's minecraft:attack_damage (1.0 without a player).
  • melee_damage (game.rs), the mace's sweep (mace.rs) and the spear's jab (spear.rs) use it instead of 1.0 + item.
  • effect_attack_bonus is removed: Strength and Weakness are modifiers on the attribute, so adding them again would count them twice (Strength I would hit for 14 with a diamond sword instead of 11).

The attack speed still adds the item's speed by hand (main_hand_attack_speed); that is left for a separate pull request.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

From the 26.3 jar (javap -c):

  • Player.attack: float damage = isAutoSpinAttack() ? autoSpinAttackDmg : (float) getAttributeValue(Attributes.ATTACK_DAMAGE); nothing else is added before the attack strength scale, getEnchantedDamage, Item.getAttackDamageBonus and the critical hit.
  • Player.createAttributes: ATTACK_DAMAGE with base 1.0.
  • MobEffects: Strength addAttributeModifier(ATTACK_DAMAGE, "effect.strength", 3.0, ADD_VALUE), Weakness addAttributeModifier(ATTACK_DAMAGE, "effect.weakness", -4.0, ADD_VALUE).
  • The weapon's attribute_modifiers reach the attribute through LivingEntity.collectEquipmentChanges (#4132).

Self-check

pr_ready (tools/pr_ready.py --quick on gentoo-pc, against origin/main at 6ee48d0e4, 4 min 14 s)

Check Result
Scope ✅ 8 files, +27 −19
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (32 s)
rustfmt ✅ (5 s)
clippy ✅ (40 s)
tests: horizon-client ✅ 1321 passed (3 min 17 s)
doc tests ✅ 0 passed (1 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 ➖ 356 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 344 more

🔄 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/5017 **Author:** [@Username59138](https://github.com/Username59138) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/melee-attack-damage-attribute` --- ### 📝 Commits (1) - [`b8b6196`](https://github.com/horizon-rust/horizon/commit/b8b6196026da808107a369fd3573a660897623d0) Melee damage reads the attack_damage attribute ### 📊 Changes **5 files changed** (+14 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+2 -6) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+0 -8) 📝 `crates/horizon-client/src/game/hand.rs` (+10 -0) 📝 `crates/horizon-client/src/game/mace.rs` (+1 -2) 📝 `crates/horizon-client/src/game/spear.rs` (+1 -3) </details> ### 📄 Description ## What and why Fixes #4191. `/attribute @s minecraft:attack_damage base set 50` (or `modifier add`) changed the attribute but not a hit: `melee_damage` built the damage by hand as `1.0 + the held item's damage + Strength/Weakness` and never read the attribute. Vanilla's `Player.attack` takes the damage from `getAttributeValue(ATTACK_DAMAGE)` alone: the base 1.0, the weapon's modifiers and the effects' modifiers are all on the attribute. Since #4132 the main hand's modifiers reach Horizon's attribute map too, and the effects' already did (`apply_effect_status`), so the attack now reads the attribute the same way: - `hand.rs`: `attack_damage()`, the player's `minecraft:attack_damage` (1.0 without a player). - `melee_damage` (`game.rs`), the mace's sweep (`mace.rs`) and the spear's jab (`spear.rs`) use it instead of `1.0 + item`. - `effect_attack_bonus` is removed: Strength and Weakness are modifiers on the attribute, so adding them again would count them twice (Strength I would hit for 14 with a diamond sword instead of 11). The attack speed still adds the item's speed by hand (`main_hand_attack_speed`); that is left for a separate pull request. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference From the 26.3 jar (`javap -c`): - `Player.attack`: `float damage = isAutoSpinAttack() ? autoSpinAttackDmg : (float) getAttributeValue(Attributes.ATTACK_DAMAGE)`; nothing else is added before the attack strength scale, `getEnchantedDamage`, `Item.getAttackDamageBonus` and the critical hit. - `Player.createAttributes`: `ATTACK_DAMAGE` with base 1.0. - `MobEffects`: Strength `addAttributeModifier(ATTACK_DAMAGE, "effect.strength", 3.0, ADD_VALUE)`, Weakness `addAttributeModifier(ATTACK_DAMAGE, "effect.weakness", -4.0, ADD_VALUE)`. - The weapon's `attribute_modifiers` reach the attribute through `LivingEntity.collectEquipmentChanges` (#4132). ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on gentoo-pc, against origin/main at 6ee48d0e4, 4 min 14 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +27 −19 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (32 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (40 s) | | tests: horizon-client | ✅ 1321 passed (3 min 17 s) | | doc tests | ✅ 0 passed (1 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 | ➖ 356 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 344 more | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:35 +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#6009
No description provided.