[PR #7597] Native hook: NoteBlockEvent.Change (note_block_change) #7702

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

📋 Pull Request Information

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

Base: main ← Head: v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note


📝 Commits (5)

  • 42de84a Expose note block tuning hook
  • a61ff00 Document note tuning hook contract
  • 5833c99 Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note
  • 608b08c Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note
  • d4ff1af Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note

📊 Changes

8 files changed (+133 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+19 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+17 -2)
📝 crates/horizon-client/src/mod_api.rs (+10 -0)
📝 crates/horizon-client/src/mod_api/generated.rs (+44 -0)
📝 crates/horizon-world/src/level/interact.rs (+18 -0)
📝 crates/horizon-world/src/level/mod.rs (+10 -0)
➕ tools/native-hook-fragments/native_note_block_change.json (+14 -0)
📝 xtask/src/mod_api.rs (+1 -0)

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Part of #4953.

Hook NeoForge 26.3 counterpart Side Contract Where vanilla fires
note_block_change NoteBlockEvent.Change Server Cancel or mutate the proposed note in order NoteBlock.useWithoutItem, after cycling NOTE and before updating the block and playing the note

What changed and why

A server-side tuning interaction reports the dimension, block position, instrument, old note and vanilla's proposed new note. Mods can replace the new note (0–24) or cancel the tune. An out-of-range replacement keeps vanilla's proposed note. Cancellation leaves the old note and prevents playback; the interaction returns Success, so the arm still swings. The NeoForge javadoc does not specify the interaction result. Client prediction does not dispatch this hook.

Overlap: question for review

The existing native_note_play is a playback hook, used beyond tuning and without the old and proposed new notes. This new hook represents a change rather than a sound. Should both remain separate as they are here?

Tests

Hook How it was checked
note_block_change In game at 608b08c2c0: server-thread baseline, cancellation and replacement; dedicated server replacement and once-per-click check.

At merge head d4ff1afd96, the Rust test run had six known local-only piston failures caused by the local game data; these pass in CI (as in #7224): a_client_replays_a_pistons_block_event, dust_on_a_downward_piston_survives_extend_and_retract, lever_on_piston_back_survives_extend_and_retract, pistons_pop_fragile_blocks_and_refuse_obsidian, pistons_push_and_sticky_pistons_pull, and refused_sticky_pull_keeps_the_block_and_sends_no_event. The remaining 2473 tests passed.

Tested in game

At 608b08c2c0, a throwaway trait mod built through the launcher logged each change. A second build also logged the existing playback hook; audio was disabled. Each server-thread case right-clicked a note block starting at note 0:

  • Baseline: note 0 → 1, with one change and one playback log.
  • Cancel: note stayed at 0, with one change log and no playback log.
  • Replace: note 0 → 17, with one change and one playback log at note 17. An execute if block command confirmed the resulting state.
  • Dedicated server: an offline client right-clicked once; note 0 → 17 and the server logged exactly one change, with no replay duplicate.

The recommended end-to-end route for native mods is horizon-machine-sample. It was used here: an adapted trait-api-example bundle, built through the launcher.

pr_ready

Final merge head: d4ff1afd9603178f79dc051fd8495bb70fd6370b, base 2050c4e0f52b74ad5361f061e0a015e8bfc894b2. The in-game proof above was at the pre-merge head; this merge only incorporates upstream changes.

pr_ready (tools/pr_ready.py --quick --base 2050c4e0f5 on 5d15b612d244, against 2050c4e0f5 at 2050c4e0f, 14 min 51 s)

Check Result
Scope ✅ 8 files, +133 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (47 s)
rustfmt ✅ (11 s)
clippy ✅ (2 min 22 s)
tests: horizon-client, horizon-client-lib, horizon-world, xtask ❌ 2473 passed, 6 failed (9 min 38 s)
doc tests ✅ 0 passed (1 min 32 s)
content root tests ➖ content root untouched
mod API up to date ✅ (20 s)
tokens.css up to date ✅ (1 s)
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Dyna.


🔄 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/7597 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note` --- ### 📝 Commits (5) - [`42de84a`](https://github.com/horizon-rust/horizon/commit/42de84a1d75e6324901e1e108bc0ac1c56148e0a) Expose note block tuning hook - [`a61ff00`](https://github.com/horizon-rust/horizon/commit/a61ff00f34c7b778aee075b93ead0eb1e078b1d7) Document note tuning hook contract - [`5833c99`](https://github.com/horizon-rust/horizon/commit/5833c990f8b41afe4796cc5a520921c8d1571541) Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note - [`608b08c`](https://github.com/horizon-rust/horizon/commit/608b08c2c01860682381ba7263170fdd344005bd) Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note - [`d4ff1af`](https://github.com/horizon-rust/horizon/commit/d4ff1afd9603178f79dc051fd8495bb70fd6370b) Merge remote-tracking branch 'upstream/main' into v2/ses_01M6EA9PQK4BXKXA1BE1D8FR68-w3-block-drops-note ### 📊 Changes **8 files changed** (+133 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+19 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+17 -2) 📝 `crates/horizon-client/src/mod_api.rs` (+10 -0) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+44 -0) 📝 `crates/horizon-world/src/level/interact.rs` (+18 -0) 📝 `crates/horizon-world/src/level/mod.rs` (+10 -0) ➕ `tools/native-hook-fragments/native_note_block_change.json` (+14 -0) 📝 `xtask/src/mod_api.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. Part of #4953. | Hook | NeoForge 26.3 counterpart | Side | Contract | Where vanilla fires | | --- | --- | --- | --- | --- | | `note_block_change` | `NoteBlockEvent.Change` | Server | Cancel or mutate the proposed note in order | `NoteBlock.useWithoutItem`, after cycling `NOTE` and before updating the block and playing the note | ## What changed and why A server-side tuning interaction reports the dimension, block position, instrument, old note and vanilla's proposed new note. Mods can replace the new note (0–24) or cancel the tune. An out-of-range replacement keeps vanilla's proposed note. Cancellation leaves the old note and prevents playback; the interaction returns `Success`, so the arm still swings. The NeoForge javadoc does not specify the interaction result. Client prediction does not dispatch this hook. ## Overlap: question for review The existing `native_note_play` is a playback hook, used beyond tuning and without the old and proposed new notes. This new hook represents a change rather than a sound. Should both remain separate as they are here? ## Tests | Hook | How it was checked | | --- | --- | | `note_block_change` | In game at 608b08c2c0: server-thread baseline, cancellation and replacement; dedicated server replacement and once-per-click check. | At merge head d4ff1afd96, the Rust test run had six known local-only piston failures caused by the local game data; these pass in CI (as in #7224): `a_client_replays_a_pistons_block_event`, `dust_on_a_downward_piston_survives_extend_and_retract`, `lever_on_piston_back_survives_extend_and_retract`, `pistons_pop_fragile_blocks_and_refuse_obsidian`, `pistons_push_and_sticky_pistons_pull`, and `refused_sticky_pull_keeps_the_block_and_sends_no_event`. The remaining 2473 tests passed. ## Tested in game At 608b08c2c0, a throwaway trait mod built through the launcher logged each change. A second build also logged the existing playback hook; audio was disabled. Each server-thread case right-clicked a note block starting at note 0: - **Baseline:** note 0 → 1, with one change and one playback log. - **Cancel:** note stayed at 0, with one change log and no playback log. - **Replace:** note 0 → 17, with one change and one playback log at note 17. An `execute if block` command confirmed the resulting state. - **Dedicated server:** an offline client right-clicked once; note 0 → 17 and the server logged exactly one change, with no replay duplicate. The recommended end-to-end route for native mods is [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample). It was used here: an adapted `trait-api-example` bundle, built through the launcher. ## pr_ready Final merge head: `d4ff1afd9603178f79dc051fd8495bb70fd6370b`, base `2050c4e0f52b74ad5361f061e0a015e8bfc894b2`. The in-game proof above was at the pre-merge head; this merge only incorporates upstream changes. **pr_ready** (`tools/pr_ready.py --quick --base 2050c4e0f5` on 5d15b612d244, against 2050c4e0f5 at 2050c4e0f, 14 min 51 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +133 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (47 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (2 min 22 s) | | tests: horizon-client, horizon-client-lib, horizon-world, xtask | ❌ 2473 passed, 6 failed (9 min 38 s) | | doc tests | ✅ 0 passed (1 min 32 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (20 s) | | tokens.css up to date | ✅ (1 s) | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with Dyna. --- <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#7702
No description provided.