[PR #6927] [MERGED] Native mods: an item frame or painting about to break, cancellable (native_hanging_break) #7202

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6927
Author: @breachato
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/6697-hanging-break-hook


📝 Commits (5)

  • eda5cea Native mods: an item frame or painting about to break, cancellable (native_hanging_break)
  • c5f2812 rustfmt the frame survival check
  • 78ac0fc Merge remote-tracking branch 'upstream/main' into feat/6697-hanging-break-hook
  • 37d7740 Regenerate the mod API after merging main
  • efb76fb Merge main into #6927

📊 Changes

7 files changed (+130 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game/explosion.rs (+2 -3)
📝 crates/horizon-client/src/game/frames.rs (+35 -2)
📝 crates/horizon-client/src/game/native_hooks.rs (+19 -0)
📝 crates/horizon-client/src/game/paintings.rs (+11 -6)
📝 crates/horizon-client/src/mod_api/generated.rs (+43 -0)
📝 docs/native-mods.md (+4 -0)
➕ tools/native-hook-fragments/native_hanging_break.json (+16 -0)

📄 Description

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

What and why

Fixes #6697.

A new cancellable server hook, native_hanging_break(player, kind, pos, cancel): an item frame, a glow item frame or a painting is about to break. It's asked where BlockAttachedEntity.hurtServer or its survival check would kill one, before anything drops or sounds:

  • A guest's hit. attack_frame asks only when the frame breaks: a hit that only takes the item out isn't a break. Player.attack's painting branch asks through break_painting. A guest's Attack on a frame or painting reaches both: guest_attack aims the swapped-in guest at the entity (look_at_entity) and runs attack(), and lan_acting_uuid is that guest. player is the guest, whose state is swapped in.
  • A blast. explosion_breaks_frames and explosion_breaks_hanging, with player None.
  • The wall gone. The 100-tick survival checks in tick_item_frames and tick_paintings, with player None.

Set cancel and the entity stays as it was. break_painting now returns false for a painting a mod kept, so the blast loop and the survival loop step past it instead of looking at the same index again. As with native_hanging_place, the game's own player's hit isn't asked, nor is /kill.

It has a fragment (tools/native-hook-fragments/native_hanging_break.json, with its mod_api entry), the placeholder body that cargo run -p xtask -- mod-api filled with dispatch_hanging_break, and a paragraph in docs/native-mods.md next to native_hanging_place.

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

  • net.minecraft.world.entity.decoration.BlockAttachedEntity.hurtServer (kill and dropItem for a hit or a blast) and its tick survival check (survives() every 100 ticks).
  • ItemFrame.hurtServer: a frame holding an item only drops the item (dropItem(..., false)), and the frame breaks on the next hit.

Not run against a mod bundle here: no horizon-mixins bundle on this machine. The issue's check is the way to confirm it: on a fresh dedicated server, a protocol client sends Attack on a summoned frame and painting, and a hook line shows up and cancel keeps them.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-G0M27UC, against upstream/main at be95d4595, 17 min 3 s)

Check Result
Scope ✅ 7 files, +129 −11
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 610 passed (3 min 14 s)
rustfmt ❌ failed (17 s)
clippy ✅ (4 min 30 s)
tests: horizon-client, horizon-client-lib ✅ 2046 passed (8 min 8 s)
doc tests ✅ 0 passed (8 s)
content root tests ➖ content root untouched
mod API up to date ✅ (40 s)
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)

rustfmt's one finding (a line in tick_item_frames) is fixed in the commit after this run; cargo fmt --all --check is clean now.

🤖 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/6927 **Author:** [@breachato](https://github.com/breachato) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/6697-hanging-break-hook` --- ### 📝 Commits (5) - [`eda5cea`](https://github.com/horizon-rust/horizon/commit/eda5cea7db934b8d56df2af8167aa473458c5aaa) Native mods: an item frame or painting about to break, cancellable (native_hanging_break) - [`c5f2812`](https://github.com/horizon-rust/horizon/commit/c5f2812eccd29c95fff894d506edd78083d5b6ae) rustfmt the frame survival check - [`78ac0fc`](https://github.com/horizon-rust/horizon/commit/78ac0fce3563338d2f928f499848ce04af3f0067) Merge remote-tracking branch 'upstream/main' into feat/6697-hanging-break-hook - [`37d7740`](https://github.com/horizon-rust/horizon/commit/37d7740c2e613a3266ee882e08e29d101494afcf) Regenerate the mod API after merging main - [`efb76fb`](https://github.com/horizon-rust/horizon/commit/efb76fb19cc8716b7e9c60b5302319d184103963) Merge main into #6927 ### 📊 Changes **7 files changed** (+130 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/explosion.rs` (+2 -3) 📝 `crates/horizon-client/src/game/frames.rs` (+35 -2) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+19 -0) 📝 `crates/horizon-client/src/game/paintings.rs` (+11 -6) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+43 -0) 📝 `docs/native-mods.md` (+4 -0) ➕ `tools/native-hook-fragments/native_hanging_break.json` (+16 -0) </details> ### 📄 Description > 🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally. ## What and why Fixes #6697. A new cancellable server hook, `native_hanging_break(player, kind, pos, cancel)`: an item frame, a glow item frame or a painting is about to break. It's asked where `BlockAttachedEntity.hurtServer` or its survival check would kill one, before anything drops or sounds: - **A guest's hit.** `attack_frame` asks only when the frame breaks: a hit that only takes the item out isn't a break. `Player.attack`'s painting branch asks through `break_painting`. A guest's `Attack` on a frame or painting reaches both: `guest_attack` aims the swapped-in guest at the entity (`look_at_entity`) and runs `attack()`, and `lan_acting_uuid` is that guest. `player` is the guest, whose state is swapped in. - **A blast.** `explosion_breaks_frames` and `explosion_breaks_hanging`, with `player` None. - **The wall gone.** The 100-tick survival checks in `tick_item_frames` and `tick_paintings`, with `player` None. Set `cancel` and the entity stays as it was. `break_painting` now returns false for a painting a mod kept, so the blast loop and the survival loop step past it instead of looking at the same index again. As with `native_hanging_place`, the game's own player's hit isn't asked, nor is `/kill`. It has a fragment (`tools/native-hook-fragments/native_hanging_break.json`, with its `mod_api` entry), the placeholder body that `cargo run -p xtask -- mod-api` filled with `dispatch_hanging_break`, and a paragraph in `docs/native-mods.md` next to `native_hanging_place`. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] 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 - `net.minecraft.world.entity.decoration.BlockAttachedEntity.hurtServer` (kill and `dropItem` for a hit or a blast) and its `tick` survival check (`survives()` every 100 ticks). - `ItemFrame.hurtServer`: a frame holding an item only drops the item (`dropItem(..., false)`), and the frame breaks on the next hit. Not run against a mod bundle here: no horizon-mixins bundle on this machine. The issue's check is the way to confirm it: on a fresh dedicated server, a protocol client sends `Attack` on a summoned frame and painting, and a hook line shows up and `cancel` keeps them. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-G0M27UC, against upstream/main at be95d4595, 17 min 3 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +129 −11 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 610 passed (3 min 14 s) | | rustfmt | ❌ failed (17 s) | | clippy | ✅ (4 min 30 s) | | tests: horizon-client, horizon-client-lib | ✅ 2046 passed (8 min 8 s) | | doc tests | ✅ 0 passed (8 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (40 s) | | 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) | rustfmt's one finding (a line in `tick_item_frames`) is fixed in the commit after this run; `cargo fmt --all --check` is clean now. 🤖 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 06:35:39 +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#7202
No description provided.