[PR #7582] Native mods: living_knockback gets the attacker and what it holds (one hook) #7691

Open
opened 2026-11-03 07:22:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7582
Author: @Xmilon
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: native/knockback-before-resistance


📝 Commits (10+)

  • f9878f7 WIP: preserve knockback v1 and add attacker-aware v2
  • a4da920 Complete attacker-aware knockback v2 and regression coverage
  • df19991 Merge upstream/main
  • f7ec51c Format fireworks.rs
  • ed0f651 Native mods: no macro in the hook points (hook_points_stay_hookable)
  • 9441881 Native mods: living_knockback_v2 hands over the attacker's held items; clippy allow for the macro-free armor stand test
  • 964c882 Merge upstream/main
  • ece30ba xtask: the dispatch contract test passes the attacker's held items
  • 0c4d079 Docs: living_knockback_v2 hands over held items; v1 already fires before resistance
  • caa5aaf Merge upstream/main

📊 Changes

12 files changed (+385 additions, -15 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+23 -3)
📝 crates/horizon-client/src/game/fireworks.rs (+5 -0)
📝 crates/horizon-client/src/game/lan_pvp.rs (+6 -0)
📝 crates/horizon-client/src/game/mace.rs (+23 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+69 -1)
📝 crates/horizon-client/src/game/spear.rs (+1 -0)
📝 crates/horizon-client/src/health.rs (+67 -5)
📝 crates/horizon-client/src/mod_api/generated.rs (+14 -1)
📝 docs/native-mods.md (+1 -1)
➕ tests/test_living_knockback_hook.py (+142 -0)
📝 xtask/src/mod_api.rs (+33 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Claude Code, Claude Sonnet 5.5), not by Xmilon personally.

Closes #6444.

One hook, not two. living_knockback (LivingKnockBackEvent) already fired on the raw strength before resistance; it now also gets attacker (the attacking entity's network id, falling back to the victim's last hurt-by mob, 0 when unknown) and attacker_main / attacker_off (a player's selected and off-hand stacks, a mob's main hand; none when unknown; recorded only while a native mod is loaded), and an armor stand's sweep fires it. The earlier living_knockback_v2 hook and its fragment are gone.

Breaking, on purpose: the function gains arguments, so a mixin injection that names native_living_knockback as a raw target must take them; trait mods only gain fields on a #[non_exhaustive] event. The docs say so.

Local: cargo clippy -p horizon-client --lib --tests -- -D warnings, cargo test -p xtask, the knockback fixture test and the stamp tests pass; xtask mod-api --check clean. Not run in game since the fold.

Written by an AI agent (Claude Code, Claude Sonnet 5.5) for Xmilon


🔄 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/7582 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `native/knockback-before-resistance` --- ### 📝 Commits (10+) - [`f9878f7`](https://github.com/horizon-rust/horizon/commit/f9878f7046bb4227de53169afda122f3bc8a6d6d) WIP: preserve knockback v1 and add attacker-aware v2 - [`a4da920`](https://github.com/horizon-rust/horizon/commit/a4da92003c5abd07183508a978ecaf9cb970ba18) Complete attacker-aware knockback v2 and regression coverage - [`df19991`](https://github.com/horizon-rust/horizon/commit/df19991b9fc40dc95679d3f67c2066430d0db123) Merge upstream/main - [`f7ec51c`](https://github.com/horizon-rust/horizon/commit/f7ec51cff3d37a96b4428d78070ea6521fb4acc5) Format fireworks.rs - [`ed0f651`](https://github.com/horizon-rust/horizon/commit/ed0f651c6acbb3ef29a02bb01ef5e7e8569eab07) Native mods: no macro in the hook points (hook_points_stay_hookable) - [`9441881`](https://github.com/horizon-rust/horizon/commit/9441881bd8f7471e995726fdb93c20b7db9c0a9e) Native mods: living_knockback_v2 hands over the attacker's held items; clippy allow for the macro-free armor stand test - [`964c882`](https://github.com/horizon-rust/horizon/commit/964c882608a8bd23e1aae37dfc521e5aae261900) Merge upstream/main - [`ece30ba`](https://github.com/horizon-rust/horizon/commit/ece30baddea7396f57250a0046f22651a3e7683c) xtask: the dispatch contract test passes the attacker's held items - [`0c4d079`](https://github.com/horizon-rust/horizon/commit/0c4d07930b7253180b050d75cf0bb048c2199cd1) Docs: living_knockback_v2 hands over held items; v1 already fires before resistance - [`caa5aaf`](https://github.com/horizon-rust/horizon/commit/caa5aaf0d3bb94881c0b4567f6c73572a47717d9) Merge upstream/main ### 📊 Changes **12 files changed** (+385 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+23 -3) 📝 `crates/horizon-client/src/game/fireworks.rs` (+5 -0) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+6 -0) 📝 `crates/horizon-client/src/game/mace.rs` (+23 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+69 -1) 📝 `crates/horizon-client/src/game/spear.rs` (+1 -0) 📝 `crates/horizon-client/src/health.rs` (+67 -5) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+14 -1) 📝 `docs/native-mods.md` (+1 -1) ➕ `tests/test_living_knockback_hook.py` (+142 -0) 📝 `xtask/src/mod_api.rs` (+33 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Claude Code, Claude Sonnet 5.5), not by Xmilon personally. Closes #6444. One hook, not two. `living_knockback` (`LivingKnockBackEvent`) already fired on the raw strength before resistance; it now also gets `attacker` (the attacking entity's network id, falling back to the victim's last hurt-by mob, 0 when unknown) and `attacker_main` / `attacker_off` (a player's selected and off-hand stacks, a mob's main hand; none when unknown; recorded only while a native mod is loaded), and an armor stand's sweep fires it. The earlier `living_knockback_v2` hook and its fragment are gone. **Breaking, on purpose:** the function gains arguments, so a mixin injection that names `native_living_knockback` as a raw target must take them; trait mods only gain fields on a `#[non_exhaustive]` event. The docs say so. Local: `cargo clippy -p horizon-client --lib --tests -- -D warnings`, `cargo test -p xtask`, the knockback fixture test and the stamp tests pass; `xtask mod-api --check` clean. Not run in game since the fold. Written by an AI agent (Claude Code, Claude Sonnet 5.5) for Xmilon --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7691
No description provided.