[PR #7036] [MERGED] Native mods: CriticalHitEvent hook (critical_hit) #7285

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7036
Author: @Xmilon
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: native/critical-hit


📝 Commits (2)

  • 3d1a782 Native mods: CriticalHitEvent hook (critical_hit)
  • ea3611d critical_hit: gate before the smash bonus, vanilla's default multiplier, correct sweep doc

📊 Changes

6 files changed (+103 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -6)
📝 crates/horizon-client/src/game/armor_stands.rs (+2 -1)
📝 crates/horizon-client/src/game/dragon.rs (+1 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+26 -0)
📝 crates/horizon-client/src/mod_api/generated.rs (+42 -0)
➕ tools/native-hook-fragments/critical_hit.json (+16 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Claude Code, Sonnet 5.5), not by Xmilon personally. Codex (gpt-6.1-terra) was tried first but could not run its edit tool in this checkout, so Claude wrote it.

What and why

Closes #6988. Part of #4953.

Adds the critical_hit hook, NeoForge's CriticalHitEvent: a player's damaging melee hit on a living target asks mods whether it is critical and by what multiplier. A mod sees the target kind and vanilla's answer, and may force or deny the crit and change the 1.5 multiplier (applied only while the crit stays true).

Horizon decided the crit twice, once for the damage in melee_damage and again for the sweep, crit sound and particles in attack_effects. A hook on one of them would leave the other out of step. So the crit is now decided once, in melee_damage, and attack_effects takes it as an argument. The armor stand passes the value melee_damage returned. The vehicle and dragon-part calls pass false, as before: neither can be hit critically.

Player.attack only reaches the crit decision when the hit deals damage, so the hook fires only when base or magic damage is positive. Where it doesn't fire, the old behaviour is unchanged.

Kind

  • feature: something new for players

Vanilla reference

Player.attack, checked with tools/rea_vanilla.py against the pinned 26.3 client. The event contract comes from NeoForge's public documentation only.

Other projects' code

None.

Self-check

  • cargo run -p xtask -- mod-api, cargo fmt --all -- --check and git diff --check passed locally.
  • No client build, clippy or tests were run locally: cold builds take too long on this machine, so verify on this PR is the check. tools/pr_ready.py was not run for the same reason.
  • No new unit test: the decision lives in melee_damage, a Game method with no test fixture. The only pure piece is a one-line gate.
  • Covered: the player's own attacks on mobs, armor stands and other players (lan_pvp). Not covered: mobs' own attacks, and a dragon part (no LivingEntity, so vanilla has no crit there either).

🤖 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/7036 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/critical-hit` --- ### 📝 Commits (2) - [`3d1a782`](https://github.com/horizon-rust/horizon/commit/3d1a782d69164ef5ad2402945e2136b3948f5a8f) Native mods: CriticalHitEvent hook (critical_hit) - [`ea3611d`](https://github.com/horizon-rust/horizon/commit/ea3611dc041d4e46ea9a623787859b576ff1c637) critical_hit: gate before the smash bonus, vanilla's default multiplier, correct sweep doc ### 📊 Changes **6 files changed** (+103 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -6) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+2 -1) 📝 `crates/horizon-client/src/game/dragon.rs` (+1 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+26 -0) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+42 -0) ➕ `tools/native-hook-fragments/critical_hit.json` (+16 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Claude Code, Sonnet 5.5), not by Xmilon personally. Codex (gpt-6.1-terra) was tried first but could not run its edit tool in this checkout, so Claude wrote it. ## What and why Closes #6988. Part of #4953. Adds the `critical_hit` hook, NeoForge's `CriticalHitEvent`: a player's damaging melee hit on a living target asks mods whether it is critical and by what multiplier. A mod sees the target kind and vanilla's answer, and may force or deny the crit and change the 1.5 multiplier (applied only while the crit stays true). Horizon decided the crit twice, once for the damage in `melee_damage` and again for the sweep, crit sound and particles in `attack_effects`. A hook on one of them would leave the other out of step. So the crit is now decided once, in `melee_damage`, and `attack_effects` takes it as an argument. The armor stand passes the value `melee_damage` returned. The vehicle and dragon-part calls pass `false`, as before: neither can be hit critically. `Player.attack` only reaches the crit decision when the hit deals damage, so the hook fires only when base or magic damage is positive. Where it doesn't fire, the old behaviour is unchanged. ## Kind - [x] feature: something new for players ## Vanilla reference `Player.attack`, checked with `tools/rea_vanilla.py` against the pinned 26.3 client. The event contract comes from NeoForge's public documentation only. ## Other projects' code None. ## Self-check - `cargo run -p xtask -- mod-api`, `cargo fmt --all -- --check` and `git diff --check` passed locally. - No client build, clippy or tests were run locally: cold builds take too long on this machine, so `verify` on this PR is the check. `tools/pr_ready.py` was not run for the same reason. - No new unit test: the decision lives in `melee_damage`, a `Game` method with no test fixture. The only pure piece is a one-line gate. - Covered: the player's own attacks on mobs, armor stands and other players (`lan_pvp`). Not covered: mobs' own attacks, and a dragon part (no `LivingEntity`, so vanilla has no crit there either). 🤖 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-03 06:37:05 +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#7285
No description provided.