[PR #4739] [MERGED] Native mods: hook points that keep fluids, fire, pistons, explosions, buckets and blows out of guarded land (API 22) #5820

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4739
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: feat/smp-grief-hooks


📝 Commits (3)

  • 524071f Native mods: hook points that keep fluids, fire, pistons, explosions, buckets and blows out of guarded land (API 22)
  • 5111959 Native mods: pass the bucket's stack as it is (clippy)
  • 5f5acec Merge remote-tracking branch 'origin/main' into feat/smp-grief-hooks

📊 Changes

12 files changed (+336 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+40 -0)
📝 crates/horizon-client/src/game/explosion.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+31 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+83 -1)
📝 crates/horizon-world/src/level/fluids.rs (+7 -1)
📝 crates/horizon-world/src/level/mod.rs (+29 -0)
📝 crates/horizon-world/src/level/pistons.rs (+6 -0)
📝 crates/horizon-world/src/level/tests.rs (+81 -1)
📝 crates/horizon-world/src/level/tick.rs (+15 -9)
📝 docs/native-mods.md (+16 -0)
📝 docs/smp.md (+1 -0)
📝 native-hooks.json (+25 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Five hook points (API 22) so a server mod that guards land, like the official server's SMP claims, can keep the
world itself out of it, not only players' breaks and clicks:

Hook Where Cancel means
native_block_spread(dimension, kind, from, to, canceled) (GameLevel) FlowingFluid.spreadTo; FireBlock.tick setting fire to a block and checkBurnOut burning it the block at to stays as it is
native_piston_move(dimension, piston, direction, push, destroy, canceled) (GameLevel) PistonBaseBlock.moveBlocks, once the structure resolved nothing moves, as a structure that can't
native_explosion_detonate(dimension, center, blocks) ServerExplosion.explode's toBlow, before any block is hit a mod takes out the positions it spares
native_fill_bucket(stack, pos, canceled) BucketItem.use, where it asks mayInteract (fill and empty) the bucket does nothing
native_attack_entity(entity, kind, pos, canceled) the server's attack packet, once in reach, where Player.attack starts no damage, no knockback
  • horizon-world asks through two LevelAccess methods (allow_spread, allow_piston_move) that allow by default;
    the game calls the hooks only on an authoritative server (as the block observers do).
  • Fire asks after its random draws, so a refusal leaves vanilla's random order unchanged.
  • The attack hook is in guest_attack, so it covers single player's server thread, LAN and dedicated servers
    alike, for item frames, armor stands, paintings, vehicles, mobs and players.
  • Right-clicking an entity is #4648's (native_interact_entity), not duplicated here. No open PR adds any of these
    five (checked gh pr list --search hook and the files of #4648, #4656, #4665, #4669 and #4677).

Empty functions when no mod hooks them. Docs: docs/native-mods.md (API 22) and docs/smp.md.

Tests

  • horizon-world: refused_spread_keeps_water_out_of_a_guarded_block,
    refused_spread_keeps_fire_off_a_guarded_block, refused_piston_move_leaves_the_piston_retracted (a
    TestLevel with guarded positions); water_spreads_on_a_floor and pistons_push_and_sticky_pistons_pull are unchanged.
  • native_ tests (the catalog native-hooks.json, the hooks stay hookable).
  • End to end: the SMP mod on these hooks, proven on a dedicated server with two real clients
    (horizon-rust/horizon-mods, native/smp/proof.py world_guard). Water, fire, a piston, TNT, a bucket and a fist
    are all kept out of a claim.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at f4a81d27e, 10 min 11 s)

Check Result
Scope ✅ 12 files, +336 −12
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (1 min 14 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 13 s)
tests: horizon-client, horizon-world ❌ 1400 passed, 1 failed (7 min 10 s)
doc tests ✅ 0 passed (4 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 ➖ 125 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer and 113 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Notes on the ❌ and the parity run:

  • The one failing test, level::tests::a_candle_on_an_uneaten_cake_makes_a_candle_cake, fails the same way on main
    (062d66e49, checked in a clean worktree): not this branch.
  • The full run (with harnesses, before the merge of main): 128 affected, 125 passed. command_exec (/help) and
    chat_screen differ only by /ban, /deop, /op, /pardon and /whitelist, which main's e1a530a71 added to
    the dedicated server's tree. remote_fireball (an ender pearl seen in one sample, server thread) passed when
    run again alone: python3 tools/parity.py remote_fireball → PASS.

🤖 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/4739 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/smp-grief-hooks` --- ### 📝 Commits (3) - [`524071f`](https://github.com/horizon-rust/horizon/commit/524071f9cf4b2c69150e8fd39f6588ac04ed6f63) Native mods: hook points that keep fluids, fire, pistons, explosions, buckets and blows out of guarded land (API 22) - [`5111959`](https://github.com/horizon-rust/horizon/commit/51119592e23948699cfd1abe20eb92be09853bc8) Native mods: pass the bucket's stack as it is (clippy) - [`5f5acec`](https://github.com/horizon-rust/horizon/commit/5f5acece3fbb3ceeb9e07ae379f25cef89feff88) Merge remote-tracking branch 'origin/main' into feat/smp-grief-hooks ### 📊 Changes **12 files changed** (+336 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+40 -0) 📝 `crates/horizon-client/src/game/explosion.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+31 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+83 -1) 📝 `crates/horizon-world/src/level/fluids.rs` (+7 -1) 📝 `crates/horizon-world/src/level/mod.rs` (+29 -0) 📝 `crates/horizon-world/src/level/pistons.rs` (+6 -0) 📝 `crates/horizon-world/src/level/tests.rs` (+81 -1) 📝 `crates/horizon-world/src/level/tick.rs` (+15 -9) 📝 `docs/native-mods.md` (+16 -0) 📝 `docs/smp.md` (+1 -0) 📝 `native-hooks.json` (+25 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Five hook points (API 22) so a server mod that guards land, like the official server's SMP claims, can keep the world itself out of it, not only players' breaks and clicks: | Hook | Where | Cancel means | |---|---|---| | `native_block_spread(dimension, kind, from, to, canceled)` (`GameLevel`) | `FlowingFluid.spreadTo`; `FireBlock.tick` setting fire to a block and `checkBurnOut` burning it | the block at `to` stays as it is | | `native_piston_move(dimension, piston, direction, push, destroy, canceled)` (`GameLevel`) | `PistonBaseBlock.moveBlocks`, once the structure resolved | nothing moves, as a structure that can't | | `native_explosion_detonate(dimension, center, blocks)` | `ServerExplosion.explode`'s `toBlow`, before any block is hit | a mod takes out the positions it spares | | `native_fill_bucket(stack, pos, canceled)` | `BucketItem.use`, where it asks `mayInteract` (fill and empty) | the bucket does nothing | | `native_attack_entity(entity, kind, pos, canceled)` | the server's attack packet, once in reach, where `Player.attack` starts | no damage, no knockback | - horizon-world asks through two `LevelAccess` methods (`allow_spread`, `allow_piston_move`) that allow by default; the game calls the hooks only on an authoritative server (as the block observers do). - Fire asks after its random draws, so a refusal leaves vanilla's random order unchanged. - The attack hook is in `guest_attack`, so it covers single player's server thread, LAN and dedicated servers alike, for item frames, armor stands, paintings, vehicles, mobs and players. - Right-clicking an entity is #4648's (`native_interact_entity`), not duplicated here. No open PR adds any of these five (checked `gh pr list --search hook` and the files of #4648, #4656, #4665, #4669 and #4677). Empty functions when no mod hooks them. Docs: `docs/native-mods.md` (API 22) and `docs/smp.md`. ## Tests - horizon-world: `refused_spread_keeps_water_out_of_a_guarded_block`, `refused_spread_keeps_fire_off_a_guarded_block`, `refused_piston_move_leaves_the_piston_retracted` (a `TestLevel` with guarded positions); `water_spreads_on_a_floor` and `pistons_push_and_sticky_pistons_pull` are unchanged. - `native_` tests (the catalog `native-hooks.json`, the hooks stay hookable). - End to end: the SMP mod on these hooks, proven on a dedicated server with two real clients (horizon-rust/horizon-mods, `native/smp/proof.py` `world_guard`). Water, fire, a piston, TNT, a bucket and a fist are all kept out of a claim. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at f4a81d27e, 10 min 11 s) | Check | Result | | --- | --- | | Scope | ✅ 12 files, +336 −12 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (1 min 14 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 13 s) | | tests: horizon-client, horizon-world | ❌ 1400 passed, 1 failed (7 min 10 s) | | doc tests | ✅ 0 passed (4 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 | ➖ 125 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer and 113 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Notes on the ❌ and the parity run: - The one failing test, `level::tests::a_candle_on_an_uneaten_cake_makes_a_candle_cake`, fails the same way on main (062d66e49, checked in a clean worktree): not this branch. - The full run (with harnesses, before the merge of main): 128 affected, 125 passed. `command_exec` (`/help`) and `chat_screen` differ only by `/ban`, `/deop`, `/op`, `/pardon` and `/whitelist`, which main's e1a530a71 added to the dedicated server's tree. `remote_fireball` (an ender pearl seen in one sample, server thread) passed when run again alone: `python3 tools/parity.py remote_fireball` → PASS. 🤖 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 05:15:13 +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#5820
No description provided.