[PR #5536] [MERGED] Native mods: server-side block contact and landing damage hooks #6340

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5536
Author: @Xmilon
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/block-touch-hooks


📝 Commits (3)

  • e1c1669 feat(mods): add server-side block contact hooks
  • 69c0f83 docs: clarify landing hooks preserve block-specific sounds
  • 58f3f29 Block contact hooks: no sweep without mod blocks, vanilla's order and on-pos

📊 Changes

16 files changed (+631 additions, -51 deletions)

View changed files

📝 crates/horizon-client/src/arrows.rs (+9 -0)
➕ crates/horizon-client/src/block_contact.rs (+201 -0)
📝 crates/horizon-client/src/entities.rs (+31 -0)
📝 crates/horizon-client/src/game.rs (+7 -0)
📝 crates/horizon-client/src/game/creatures.rs (+6 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+3 -1)
📝 crates/horizon-client/src/game/levels.rs (+17 -12)
📝 crates/horizon-client/src/game/native_hooks.rs (+70 -0)
📝 crates/horizon-client/src/landing.rs (+93 -26)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/mobs/ai.rs (+22 -6)
📝 crates/horizon-client/src/mobs/living.rs (+35 -3)
📝 crates/horizon-client/src/motion.rs (+23 -0)
📝 crates/horizon-client/src/projectiles.rs (+14 -0)
📝 crates/horizon-world/src/living_fall.rs (+78 -3)
➕ tools/native-hook-fragments/block_contacts.json (+21 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Codex, GPT-6), not by Xmilon personally.

What and why

Fixes #5498. Part of #4953.

Native mods can observe an entity stepping on or entering a mod block and change a living entity's landing damage. Add block_step_on, block_entity_inside and block_fall_on as pending catalog hooks.

  • Each hook receives server dimension, entity id/type, block state and block position. block_fall_on also receives fall distance and &mut f32 calculated damage. Zero prevents generic fall-damage sounds and hurt; non-finite changes are ignored and negative damage is clamped to zero. Immunities remain in place.
  • Player/mob step and inside callbacks use their existing contact passes; items use the common geometry sweep, including idle overlap. Arrows use their existing deduplicated block sweep; other projectiles report their completed movement through the same geometry sweep.
  • Landing damage adjustment is synchronous, before generic damage sounds and hurt, for player/mob landings. Player blocks keep their existing template landing rules; rules that do not request damage still notify with zero. Mount-propagated fall damage is not a second block landing.
  • Callbacks follow the existing no-self HURT_SERVER bridge pattern. A scoped thread-local dimension enables them only on the authoritative server tick, including nested guest actions, and restores it on errors/unwind. Client prediction never enables this scope. Only non-minecraft blocks dispatch.
  • Hook registration/documentation is in tools/native-hook-fragments/block_contacts.json; no API number or generated catalog is edited. The hook contract is pending stamping after merge.

Kind

  • feature: something new for players

Vanilla reference

Horizon-only native hook surface at the existing Block.stepOn, Block.entityInside, Block.fallOn and LivingEntity.causeFallDamage paths. Existing movement/landing code and the living_fall / block_landing / arrow parity harnesses supply the vanilla behavior; no external project source was used. This machine has no prepared bytecode/resources in this worktree, so the vanilla harnesses and an in-game mod run were not performed locally.

Other projects' code

None.

Self-check

Windows, RUST_MIN_STACK=33554432, -j1:

  • cargo fmt --all -- --check: pass.
  • cargo clippy -p horizon-client -p horizon-world --lib --bins --tests -- -D warnings: pass.
  • cargo test -p horizon-world --lib living_fall: 5 passed, including unchanged damage, reduction and zero damage before sounds/hurt.
  • The actual block_contact.rs unit test was compiled/run as an isolated rustc test against this checkout's built horizon-core/horizon-world libraries, avoiding a full client test executable: passed. Covers dimension/entity/state/position, server and vanilla-block filtering, nested and panic scope restoration, damage reduction/zero/invalid values, a block crossed mid-move exactly once, and stationary overlap.
  • python -m unittest discover -s tests -p test_stamp_native_hooks.py: 3 passed.
  • Public-tree and diff checks: pass. Upstream CI verify passed on 69c0f83d8 (checks), including workspace linting and tests. The launcher job passed with its checks skipped because no launcher dependencies changed. Parity jobs were skipped; no in-game validation was performed locally. pr_ready was not run locally under this contributor's build constraints.

Scope: 16 files, about 600 added lines including callback and damage-order tests. Slightly above the guideline to keep all three contact events, shared server gating and their regression checks together. No launcher UI, format change, second API, or .hzn work.

🤖 Generated with Codex


🔄 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/5536 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/block-touch-hooks` --- ### 📝 Commits (3) - [`e1c1669`](https://github.com/horizon-rust/horizon/commit/e1c1669993f4c5002db911f3c7e6646acf3aab0c) feat(mods): add server-side block contact hooks - [`69c0f83`](https://github.com/horizon-rust/horizon/commit/69c0f83d85d68b5101c664a49cd6e6b670f09f4a) docs: clarify landing hooks preserve block-specific sounds - [`58f3f29`](https://github.com/horizon-rust/horizon/commit/58f3f290e63552455f24f21e422962621200a245) Block contact hooks: no sweep without mod blocks, vanilla's order and on-pos ### 📊 Changes **16 files changed** (+631 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/arrows.rs` (+9 -0) ➕ `crates/horizon-client/src/block_contact.rs` (+201 -0) 📝 `crates/horizon-client/src/entities.rs` (+31 -0) 📝 `crates/horizon-client/src/game.rs` (+7 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+6 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+3 -1) 📝 `crates/horizon-client/src/game/levels.rs` (+17 -12) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+70 -0) 📝 `crates/horizon-client/src/landing.rs` (+93 -26) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/ai.rs` (+22 -6) 📝 `crates/horizon-client/src/mobs/living.rs` (+35 -3) 📝 `crates/horizon-client/src/motion.rs` (+23 -0) 📝 `crates/horizon-client/src/projectiles.rs` (+14 -0) 📝 `crates/horizon-world/src/living_fall.rs` (+78 -3) ➕ `tools/native-hook-fragments/block_contacts.json` (+21 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Codex, GPT-6), not by Xmilon personally. ## What and why Fixes #5498. Part of #4953. Native mods can observe an entity stepping on or entering a mod block and change a living entity's landing damage. Add `block_step_on`, `block_entity_inside` and `block_fall_on` as pending catalog hooks. - Each hook receives server dimension, entity id/type, block state and block position. `block_fall_on` also receives fall distance and `&mut f32` calculated damage. Zero prevents generic fall-damage sounds and hurt; non-finite changes are ignored and negative damage is clamped to zero. Immunities remain in place. - Player/mob step and inside callbacks use their existing contact passes; items use the common geometry sweep, including idle overlap. Arrows use their existing deduplicated block sweep; other projectiles report their completed movement through the same geometry sweep. - Landing damage adjustment is synchronous, before generic damage sounds and hurt, for player/mob landings. Player blocks keep their existing template landing rules; rules that do not request damage still notify with zero. Mount-propagated fall damage is not a second block landing. - Callbacks follow the existing no-self `HURT_SERVER` bridge pattern. A scoped thread-local dimension enables them only on the authoritative server tick, including nested guest actions, and restores it on errors/unwind. Client prediction never enables this scope. Only non-minecraft blocks dispatch. - Hook registration/documentation is in `tools/native-hook-fragments/block_contacts.json`; no API number or generated catalog is edited. The hook contract is pending stamping after merge. ## Kind - [x] feature: something new for players ## Vanilla reference Horizon-only native hook surface at the existing `Block.stepOn`, `Block.entityInside`, `Block.fallOn` and `LivingEntity.causeFallDamage` paths. Existing movement/landing code and the `living_fall` / `block_landing` / `arrow` parity harnesses supply the vanilla behavior; no external project source was used. This machine has no prepared bytecode/resources in this worktree, so the vanilla harnesses and an in-game mod run were not performed locally. ## Other projects' code None. ## Self-check Windows, `RUST_MIN_STACK=33554432`, `-j1`: - `cargo fmt --all -- --check`: pass. - `cargo clippy -p horizon-client -p horizon-world --lib --bins --tests -- -D warnings`: pass. - `cargo test -p horizon-world --lib living_fall`: 5 passed, including unchanged damage, reduction and zero damage before sounds/hurt. - The actual `block_contact.rs` unit test was compiled/run as an isolated rustc test against this checkout's built horizon-core/horizon-world libraries, avoiding a full client test executable: passed. Covers dimension/entity/state/position, server and vanilla-block filtering, nested and panic scope restoration, damage reduction/zero/invalid values, a block crossed mid-move exactly once, and stationary overlap. - `python -m unittest discover -s tests -p test_stamp_native_hooks.py`: 3 passed. - Public-tree and diff checks: pass. Upstream CI `verify` passed on `69c0f83d8` ([checks](https://github.com/horizon-rust/horizon/actions/runs/41247737320)), including workspace linting and tests. The launcher job passed with its checks skipped because no launcher dependencies changed. Parity jobs were skipped; no in-game validation was performed locally. `pr_ready` was not run locally under this contributor's build constraints. Scope: 16 files, about 600 added lines including callback and damage-order tests. Slightly above the guideline to keep all three contact events, shared server gating and their regression checks together. No launcher UI, format change, second API, or `.hzn` work. 🤖 Generated with [Codex](https://openai.com/codex/) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:18:34 +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#6340
No description provided.