[GH-ISSUE #4191] Melee damage ignores the attack_damage attribute: /attribute base set and modifiers don't change a hit #1235

Closed
opened 2026-11-02 15:45:18 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Username59138 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4191

Originally assigned to: @Username59138 on GitHub.

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

What: /attribute @s minecraft:attack_damage base set 50 (or modifier add) changes the attribute, but a hit still deals the old damage. Found in game on the default server thread; other attributes the player changes this way do work.

Cause: melee_damage (game.rs) builds the damage by hand and never reads the attribute:

let hand_damage = 1.0 + self.attack_item_info().map_or(0.0, |i| i.attack_damage);
...
hand_damage + self.effect_attack_bonus()

The same 1.0 + item sum is in mace.rs (sweep_base_damage caller) and spear.rs. main_hand_attack_speed (hand.rs) likewise adds the item's speed to BASE_ATTACK_SPEED instead of reading attack_speed.

Vanilla 26.3 (javap -c on the jar): Player.attack takes isAutoSpinAttack() ? autoSpinAttackDmg : (float) getAttributeValue(ATTACK_DAMAGE) and adds nothing else before the attack strength, getEnchantedDamage, getAttackDamageBonus and the critical hit. Everything else is a modifier on the attribute: the base 1.0 (Player.createAttributes), the weapon's attribute_modifiers (LivingEntity.collectEquipmentChanges), Strength +3.0 ADD_VALUE and Weakness -4.0 ADD_VALUE (MobEffects), and /attribute's own modifiers.

Depends on #4132. Horizon already applies the effects' modifiers to the player (apply_effect_status), but the main hand's only reach the attribute map with #4132 (#4118). Reading the attribute before that lands would make every weapon hit for 1.0, and keeping + item / effect_attack_bonus() after it would count them twice.

Fix (after #4132): melee_damage, the mace and the spear read attack_damage, dropping + item and effect_attack_bonus(); main_hand_attack_speed reads attack_speed.

Originally created by @Username59138 on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4191 Originally assigned to: @Username59138 on GitHub. > 🤖 Filed by Username59138's AI agent (Claude Code, Claude Opus 5.5), not by Username59138 personally. **What:** `/attribute @s minecraft:attack_damage base set 50` (or `modifier add`) changes the attribute, but a hit still deals the old damage. Found in game on the default server thread; other attributes the player changes this way do work. **Cause:** `melee_damage` (`game.rs`) builds the damage by hand and never reads the attribute: ```rust let hand_damage = 1.0 + self.attack_item_info().map_or(0.0, |i| i.attack_damage); ... hand_damage + self.effect_attack_bonus() ``` The same `1.0 + item` sum is in `mace.rs` (`sweep_base_damage` caller) and `spear.rs`. `main_hand_attack_speed` (`hand.rs`) likewise adds the item's speed to `BASE_ATTACK_SPEED` instead of reading `attack_speed`. **Vanilla 26.3** (`javap -c` on the jar): `Player.attack` takes `isAutoSpinAttack() ? autoSpinAttackDmg : (float) getAttributeValue(ATTACK_DAMAGE)` and adds nothing else before the attack strength, `getEnchantedDamage`, `getAttackDamageBonus` and the critical hit. Everything else is a modifier on the attribute: the base 1.0 (`Player.createAttributes`), the weapon's `attribute_modifiers` (`LivingEntity.collectEquipmentChanges`), Strength `+3.0 ADD_VALUE` and Weakness `-4.0 ADD_VALUE` (`MobEffects`), and `/attribute`'s own modifiers. **Depends on #4132.** Horizon already applies the effects' modifiers to the player (`apply_effect_status`), but the main hand's only reach the attribute map with #4132 (#4118). Reading the attribute before that lands would make every weapon hit for 1.0, and keeping `+ item` / `effect_attack_bonus()` after it would count them twice. **Fix (after #4132):** `melee_damage`, the mace and the spear read `attack_damage`, dropping `+ item` and `effect_attack_bonus()`; `main_hand_attack_speed` reads `attack_speed`.
Author
Owner

@Username59138 commented on GitHub (Oct 30, 2026):

/claim

<!-- gh-comment-id:6515801748 --> @Username59138 commented on GitHub (Oct 30, 2026): /claim
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#1235
No description provided.