[PR #4899] [MERGED] feat(mods): native mods can change their blocks on shape updates #5928

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4899
Author: @reservedbytes
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: feat/native-shape-update


📝 Commits (2)

  • 717b49c feat(mods): native mods can change their blocks on shape updates
  • f96b795 Merge hr/main; renumber shape-update hook to API 32; validate a mod's state id; cover the incoming state in the test

📊 Changes

7 files changed (+320 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+23 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+93 -3)
📝 crates/horizon-world/src/level/mod.rs (+18 -0)
📝 crates/horizon-world/src/level/shapes.rs (+16 -0)
📝 crates/horizon-world/src/level/tests.rs (+148 -0)
📝 docs/native-mods.md (+17 -0)
📝 native-hooks.json (+5 -0)

📄 Description

What and why

A native mod can't decide how its blocks react to a neighbour yet (connecting, attaching, breaking when unsupported)

native_update_shape fires where BlockState.updateShape starts, so neighbour updates, pistons, post-processing and a feature's edge as it's placed in the world all reach it
The mod sets new to its block's new state and the block's own updateShape doesn't run
Air breaks the block with its drops on a neighbour update, as updateOrDestroy does

Like vanilla's updateShape, the level is read only but the hook gets the scheduled ticks
native_schedule_block_tick and native_schedule_fluid_tick let a mod schedule what its block needs (a waterlogged block's water tick), without writing blocks

state may not be in the world yet (a piston landing it), so a mod decides from state
It runs at least six times per setBlock, so it should stay short
A LAN guest shows vanilla's shape for a moment until the server's update comes

Without a mod it adds nothing per update in an optimized build (one loop gets unrolled, same calls)
With a mod installed but its block absent it's about 3 ns per update

This bumps the hook points API to 23 (renumbered at merge if needed)

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

BlockBehaviour.updateShape (LevelReader, ScheduledTickAccess), Block.updateOrDestroy

Self-check

The one failure is a_candle_on_an_uneaten_cake_makes_a_candle_cake (#4780)

Check Result
Scope ✅ 7 files, +293 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (55 s)
rustfmt ✅ (8 s)
clippy ✅ (2 min 20 s)
tests: horizon-client, horizon-world ❌ 1492 passed, 1 failed (7 min 1 s)
doc tests ✅ 0 passed (3 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)

🔄 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/4899 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat/native-shape-update` --- ### 📝 Commits (2) - [`717b49c`](https://github.com/horizon-rust/horizon/commit/717b49cbc98151134c20b1c7a1d64b4b08315636) feat(mods): native mods can change their blocks on shape updates - [`f96b795`](https://github.com/horizon-rust/horizon/commit/f96b795bf66772dca2aa2e7bc28cf5af1a1e3a40) Merge hr/main; renumber shape-update hook to API 32; validate a mod's state id; cover the incoming state in the test ### 📊 Changes **7 files changed** (+320 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+23 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+93 -3) 📝 `crates/horizon-world/src/level/mod.rs` (+18 -0) 📝 `crates/horizon-world/src/level/shapes.rs` (+16 -0) 📝 `crates/horizon-world/src/level/tests.rs` (+148 -0) 📝 `docs/native-mods.md` (+17 -0) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description ## What and why A native mod can't decide how its blocks react to a neighbour yet (connecting, attaching, breaking when unsupported) `native_update_shape` fires where `BlockState.updateShape` starts, so neighbour updates, pistons, post-processing and a feature's edge as it's placed in the world all reach it The mod sets `new` to its block's new state and the block's own `updateShape` doesn't run Air breaks the block with its drops on a neighbour update, as `updateOrDestroy` does Like vanilla's `updateShape`, the level is read only but the hook gets the scheduled ticks `native_schedule_block_tick` and `native_schedule_fluid_tick` let a mod schedule what its block needs (a waterlogged block's water tick), without writing blocks `state` may not be in the world yet (a piston landing it), so a mod decides from `state` It runs at least six times per `setBlock`, so it should stay short A LAN guest shows vanilla's shape for a moment until the server's update comes Without a mod it adds nothing per update in an optimized build (one loop gets unrolled, same calls) With a mod installed but its block absent it's about 3 ns per update This bumps the hook points API to 23 (renumbered at merge if needed) ## 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 `BlockBehaviour.updateShape` (`LevelReader`, `ScheduledTickAccess`), `Block.updateOrDestroy` ## Self-check The one failure is `a_candle_on_an_uneaten_cake_makes_a_candle_cake` (#4780) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +293 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (55 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (2 min 20 s) | | tests: horizon-client, horizon-world | ❌ 1492 passed, 1 failed (7 min 1 s) | | doc tests | ✅ 0 passed (3 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) | --- <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:59 +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#5928
No description provided.