[PR #6270] [MERGED] Native mods: a player finishing a sign, rewritable or cancellable (native_sign_changed, part of #5816) #6759

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6270
Author: @Detimes
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat-sign-changed-hook


📝 Commits (2)

  • d4ff4ae Native mods: a player finishing a sign, rewritable or cancellable (native_sign_changed)
  • 6b6b552 Merge upstream/main: keep both hooks

📊 Changes

4 files changed (+95 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+28 -0)
📝 crates/horizon-client/src/game/sign_edit.rs (+48 -1)
📝 docs/native-mods.md (+6 -0)
➕ tools/native-hook-fragments/native_sign_changed.json (+13 -0)

📄 Description

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

What and why

Part of #5816 (hook points a survival server's native mods need). A native mod could not see what a player writes on a sign, so it could not filter, rewrite or refuse it.

  • New hook point native_sign_changed(player, name, dimension, pos, front, lines, cancel), API number from the fragment (tools/native-hook-fragments/native_sign_changed.json), a paragraph in docs/native-mods.md.
  • Called from lan_sign_update (sign_edit.rs) through as_guest_messaged, so the player's state is swapped in and native_tell / native_acting_player work inside it. It fires after the editing check, the reach check, the chat filter and the waxed check, right before the lines are written: the mod may rewrite lines (resized back to 4; rewritten lines get no second chat-filter pass) or set cancel, which keeps the old text, closes the editor and resends the block entity.
  • Nothing changes when no mod hooks it.

Kind

  • feature (new native hook point)

Vanilla reference

ServerGamePacketListenerImpl.updateSignText (the server side of the sign editor). NeoForge has no sign-editing event; Bukkit's SignChangeEvent is the equivalent (the fragment says so).

Other projects' code

none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.)

Proof on a real dedicated server

Engine built from this branch plus a throwaway horizon-mixins bundle. A console setblock places an oak_sign with "old one" / "old two"; a bare protocol client right-clicks it (the server sends OpenSignEditor) and sends the update.

control: update for a sign nobody opened  -> refused ("tried to change non-editable sign"), hook silent, text stays "old one"
uppercase run, server log:
  helpers: native_acting_player=Some("SignProbe") native_tell=true
  sign changed: player=SignProbe dim=minecraft:overworld pos=[18, 63, 6] front=true lines=["hello world","second line","","bye"]
  first line uppercased -> "HELLO WORLD"
  data get block: messages: ["HELLO WORLD", "second line", "", "bye"]
  the client received the system chat "helper reached you"
cancel run: server log "cancelling"; data get block afterwards: messages: ["old one", "old two", "", ""]

Not covered: the LAN or single-player host's own sign editor, a waxed sign (the check comes before the hook; not exercised), the back side, and non-edit changes (dye, glow ink, wax, /data, /setblock, native_with_mod_block_entity), which are named in the doc comment.

Self-check

pr_ready --quick --base upstream/main before merging main into the branch: Python tests 515 passed, rustfmt pass, clippy pass, horizon-client tests 1668 passed, doc tests pass, parity not run (--quick). After the merge: cargo test -p horizon-client --bin horizon-client native_hooks::tests passes (20 tests).


🔄 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/6270 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat-sign-changed-hook` --- ### 📝 Commits (2) - [`d4ff4ae`](https://github.com/horizon-rust/horizon/commit/d4ff4aecef02625079c42528c422bb81f82b5980) Native mods: a player finishing a sign, rewritable or cancellable (native_sign_changed) - [`6b6b552`](https://github.com/horizon-rust/horizon/commit/6b6b5527959181dc2b3f95d48aa152c74918e0a1) Merge upstream/main: keep both hooks ### 📊 Changes **4 files changed** (+95 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+28 -0) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+48 -1) 📝 `docs/native-mods.md` (+6 -0) ➕ `tools/native-hook-fragments/native_sign_changed.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally. ## What and why Part of #5816 (hook points a survival server's native mods need). A native mod could not see what a player writes on a sign, so it could not filter, rewrite or refuse it. - New hook point `native_sign_changed(player, name, dimension, pos, front, lines, cancel)`, API number from the fragment (`tools/native-hook-fragments/native_sign_changed.json`), a paragraph in `docs/native-mods.md`. - Called from `lan_sign_update` (`sign_edit.rs`) through `as_guest_messaged`, so the player's state is swapped in and `native_tell` / `native_acting_player` work inside it. It fires after the editing check, the reach check, the chat filter and the waxed check, right before the lines are written: the mod may rewrite `lines` (resized back to 4; rewritten lines get no second chat-filter pass) or set `cancel`, which keeps the old text, closes the editor and resends the block entity. - Nothing changes when no mod hooks it. ## Kind - [x] feature (new native hook point) ## Vanilla reference `ServerGamePacketListenerImpl.updateSignText` (the server side of the sign editor). NeoForge has no sign-editing event; Bukkit's `SignChangeEvent` is the equivalent (the fragment says so). ## Other projects' code none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.) ## Proof on a real dedicated server Engine built from this branch plus a throwaway horizon-mixins bundle. A console `setblock` places an `oak_sign` with "old one" / "old two"; a bare protocol client right-clicks it (the server sends OpenSignEditor) and sends the update. ``` control: update for a sign nobody opened -> refused ("tried to change non-editable sign"), hook silent, text stays "old one" uppercase run, server log: helpers: native_acting_player=Some("SignProbe") native_tell=true sign changed: player=SignProbe dim=minecraft:overworld pos=[18, 63, 6] front=true lines=["hello world","second line","","bye"] first line uppercased -> "HELLO WORLD" data get block: messages: ["HELLO WORLD", "second line", "", "bye"] the client received the system chat "helper reached you" cancel run: server log "cancelling"; data get block afterwards: messages: ["old one", "old two", "", ""] ``` Not covered: the LAN or single-player host's own sign editor, a waxed sign (the check comes before the hook; not exercised), the back side, and non-edit changes (dye, glow ink, wax, `/data`, `/setblock`, `native_with_mod_block_entity`), which are named in the doc comment. ## Self-check `pr_ready --quick --base upstream/main` before merging main into the branch: Python tests 515 passed, rustfmt pass, clippy pass, `horizon-client` tests 1668 passed, doc tests pass, parity not run (`--quick`). After the merge: `cargo test -p horizon-client --bin horizon-client native_hooks::tests` passes (20 tests). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:26:12 +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#6759
No description provided.