[PR #4543] [MERGED] Fire the default_block_use and any_block_use advancement triggers #5686

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4543
Author: @AurelienBelloir
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: parity/default-and-any-block-use


📝 Commits (3)

  • 6a52889 Fire the default_block_use and any_block_use advancement triggers
  • 6dba457 Merge remote-tracking branch 'origin/main' into parity/default-and-any-block-use
  • 7553d73 Keep a failed use on a block from firing any_block_use

📊 Changes

9 files changed (+198 additions, -14 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+30 -4)
📝 crates/horizon-client/src/game/advancements.rs (+32 -0)
📝 crates/horizon-client/src/game/chiseled_bookshelf.rs (+5 -0)
📝 crates/horizon-client/src/game/decorated_pot.rs (+2 -0)
📝 crates/horizon-client/src/game/jukebox.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+8 -0)
📝 crates/horizon-world/src/level/interact.rs (+55 -9)
📝 crates/horizon-world/src/level/mod.rs (+1 -1)
📝 crates/horizon-world/src/level/tests.rs (+63 -0)

📄 Description

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

What and why

Horizon never fired the minecraft:default_block_use and minecraft:any_block_use advancement triggers, so data packs that use them could not grant those advancements. BlazeandCave's Advancements Pack (1.21.1, pack format 121) has 14 such advancements: ringing bells, pressing buttons, flipping levers, tuning note blocks, opening a trapped chest, and four technical *_fail checks that are now never tripped.

  • Behaviours::use_item_on_branch (horizon-world) returns the result together with which part of BlockState answered: useItemOn, or useWithoutItem after TRY_WITH_EMPTY_HAND. use_item_on keeps its signature and calls it.
  • use_hand fires default_block_use when useWithoutItem consumes the click, and item_used_on_block (with the stack from before the use) when the generic useItemOn does. Before this, that second case fired nothing either: candles snuffed by hand, copper golem statues.
  • The handlers that sit in front of the generic path fire default_block_use on their useWithoutItem branch: jukebox eject, decorated pot wobble, chiseled bookshelf book removal.
  • handleUseItemOn (game/lan_actions.rs) fires any_block_use when the use consumed the action, with the hand's stack as the use left it. A new use_failed flag keeps the two FAIL results of use_hand (UseResult::Fail, a block item that could not be placed) out of it.

Fixes #4499

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Read from the 26.3 bytecode with javap -c:

  • ServerPlayerGameMode.useItemOn: BlockState.useItemOn consuming → ITEM_USED_ON_BLOCK (stack copied before the use); TryEmptyHandInteraction on MAIN_HAND → BlockState.useWithoutItem consuming → DEFAULT_BLOCK_USE.trigger(player, pos).
  • ServerGamePacketListenerImpl.handleUseItemOn: gameMode.useItemOn(...) consuming → ANY_BLOCK_USE.trigger(player, hit.getBlockPos(), itemstack), where itemstack is the hand's live stack (getItemInHand), so the criterion sees it after the use.
  • DefaultBlockInteractionTrigger.trigger: ORIGIN = Vec3.atCenterOf(pos), THIS_ENTITY, BLOCK_STATE, param set BLOCK_USE (no tool).
  • AnyBlockInteractionTrigger.trigger: the same plus optional BLOCK_ENTITY and TOOL, param set ADVANCEMENT_LOCATION.

Harness: none new. level::tests::use_on_a_block_says_which_branch_answered checks the branch split (lever with and without an item, glowstone on an anchor, a lit candle by hand, bone meal on a growing sweet berry bush). The triggers themselves have no harness yet, and I don't know of an existing one for advancement triggers that I could extend. Glad to add one if you can point me to the right place.

Known gaps, left out to keep this small: a spectator's UseItemOn that opens a menu (CONSUME in vanilla) does not fire any_block_use. Some specialised handlers in front of the generic path (lectern, composter, vault, beehive, shelf…) have not been checked one by one for a useWithoutItem branch.

Self-check

pr_ready (tools/pr_ready.py --quick on ORDIECOLE, against origin/main at 1da354b67, 16 min 17 s)

Check Result
Scope ✅ 9 files, +190 −13
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (2 min 29 s)
rustfmt ✅ (23 s)
clippy ✅ (3 min 59 s)
tests: horizon-client, horizon-world ❌ failed (8 min 49 s)
doc tests ✅ 0 passed (16 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 ➖ 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)

The test row failed because of this machine, not the change: the first run ran out of memory and disk mid-build (rustc crashed with STATUS_STACK_BUFFER_OVERRUN). I reran the same tests by hand with CARGO_INCREMENTAL=0 cargo test -j 2 --no-fail-fast -p horizon-client -p horizon-world --lib --bins --tests, with prepared 26.3 resources in HORIZON_RESOURCES:

  • horizon-client: lib 780 passed, 1 failed; bin 240 passed; horizon-ctl 18 passed; all 8 integration suites pass
  • horizon-world: lib 204 passed (the new use_on_a_block_says_which_branch_answered among them), all integration suites pass

The one failure, title::tests::each_world_preset_writes_its_own_generator, happens on Windows only and is already on main: the test names a folder after the preset id (minecraft:normal), and Windows refuses : in file names. A separate one-line PR fixes it.

🤖 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/4543 **Author:** [@AurelienBelloir](https://github.com/AurelienBelloir) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `parity/default-and-any-block-use` --- ### 📝 Commits (3) - [`6a52889`](https://github.com/horizon-rust/horizon/commit/6a528894ad8d58ae6604c171371942551ef11d15) Fire the default_block_use and any_block_use advancement triggers - [`6dba457`](https://github.com/horizon-rust/horizon/commit/6dba457703363a90e5f140503b9a3d6f7fa0c9c5) Merge remote-tracking branch 'origin/main' into parity/default-and-any-block-use - [`7553d73`](https://github.com/horizon-rust/horizon/commit/7553d7356c520bdf922aa5a48bafbe5fe84e301c) Keep a failed use on a block from firing any_block_use ### 📊 Changes **9 files changed** (+198 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+30 -4) 📝 `crates/horizon-client/src/game/advancements.rs` (+32 -0) 📝 `crates/horizon-client/src/game/chiseled_bookshelf.rs` (+5 -0) 📝 `crates/horizon-client/src/game/decorated_pot.rs` (+2 -0) 📝 `crates/horizon-client/src/game/jukebox.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+8 -0) 📝 `crates/horizon-world/src/level/interact.rs` (+55 -9) 📝 `crates/horizon-world/src/level/mod.rs` (+1 -1) 📝 `crates/horizon-world/src/level/tests.rs` (+63 -0) </details> ### 📄 Description > 🤖 Opened by AurelienBelloir's AI agent (Claude Code, Claude Opus 5.5), not by AurelienBelloir personally. ## What and why Horizon never fired the `minecraft:default_block_use` and `minecraft:any_block_use` advancement triggers, so data packs that use them could not grant those advancements. BlazeandCave's Advancements Pack (1.21.1, pack format 121) has 14 such advancements: ringing bells, pressing buttons, flipping levers, tuning note blocks, opening a trapped chest, and four technical `*_fail` checks that are now never tripped. - `Behaviours::use_item_on_branch` (horizon-world) returns the result together with which part of `BlockState` answered: `useItemOn`, or `useWithoutItem` after `TRY_WITH_EMPTY_HAND`. `use_item_on` keeps its signature and calls it. - `use_hand` fires `default_block_use` when `useWithoutItem` consumes the click, and `item_used_on_block` (with the stack from before the use) when the generic `useItemOn` does. Before this, that second case fired nothing either: candles snuffed by hand, copper golem statues. - The handlers that sit in front of the generic path fire `default_block_use` on their `useWithoutItem` branch: jukebox eject, decorated pot wobble, chiseled bookshelf book removal. - `handleUseItemOn` (game/lan_actions.rs) fires `any_block_use` when the use consumed the action, with the hand's stack as the use left it. A new `use_failed` flag keeps the two `FAIL` results of `use_hand` (`UseResult::Fail`, a block item that could not be placed) out of it. Fixes #4499 ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Read from the 26.3 bytecode with `javap -c`: - `ServerPlayerGameMode.useItemOn`: `BlockState.useItemOn` consuming → `ITEM_USED_ON_BLOCK` (stack copied before the use); `TryEmptyHandInteraction` on `MAIN_HAND` → `BlockState.useWithoutItem` consuming → `DEFAULT_BLOCK_USE.trigger(player, pos)`. - `ServerGamePacketListenerImpl.handleUseItemOn`: `gameMode.useItemOn(...)` consuming → `ANY_BLOCK_USE.trigger(player, hit.getBlockPos(), itemstack)`, where `itemstack` is the hand's live stack (`getItemInHand`), so the criterion sees it after the use. - `DefaultBlockInteractionTrigger.trigger`: `ORIGIN` = `Vec3.atCenterOf(pos)`, `THIS_ENTITY`, `BLOCK_STATE`, param set `BLOCK_USE` (no tool). - `AnyBlockInteractionTrigger.trigger`: the same plus optional `BLOCK_ENTITY` and `TOOL`, param set `ADVANCEMENT_LOCATION`. Harness: none new. `level::tests::use_on_a_block_says_which_branch_answered` checks the branch split (lever with and without an item, glowstone on an anchor, a lit candle by hand, bone meal on a growing sweet berry bush). The triggers themselves have no harness yet, and I don't know of an existing one for advancement triggers that I could extend. Glad to add one if you can point me to the right place. Known gaps, left out to keep this small: a spectator's `UseItemOn` that opens a menu (`CONSUME` in vanilla) does not fire `any_block_use`. Some specialised handlers in front of the generic path (lectern, composter, vault, beehive, shelf…) have not been checked one by one for a `useWithoutItem` branch. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ORDIECOLE, against origin/main at 1da354b67, 16 min 17 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +190 −13 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (2 min 29 s) | | rustfmt | ✅ (23 s) | | clippy | ✅ (3 min 59 s) | | tests: horizon-client, horizon-world | ❌ failed (8 min 49 s) | | doc tests | ✅ 0 passed (16 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 | ➖ 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) | The test row failed because of this machine, not the change: the first run ran out of memory and disk mid-build (rustc crashed with STATUS_STACK_BUFFER_OVERRUN). I reran the same tests by hand with `CARGO_INCREMENTAL=0 cargo test -j 2 --no-fail-fast -p horizon-client -p horizon-world --lib --bins --tests`, with prepared 26.3 resources in `HORIZON_RESOURCES`: - horizon-client: lib 780 passed, 1 failed; bin 240 passed; horizon-ctl 18 passed; all 8 integration suites pass - horizon-world: lib 204 passed (the new `use_on_a_block_says_which_branch_answered` among them), all integration suites pass The one failure, `title::tests::each_world_preset_writes_its_own_generator`, happens on Windows only and is already on main: the test names a folder after the preset id (`minecraft:normal`), and Windows refuses `:` in file names. A separate one-line PR fixes it. 🤖 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:14:19 +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#5686
No description provided.