[PR #4880] [MERGED] feat(mods): native mods can change their blocks on scheduled ticks #5913

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

📋 Pull Request Information

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

Base: main ← Head: feat/native-scheduled-tick


📝 Commits (2)

  • 6521dff feat(mods): native mods can change their blocks on scheduled ticks
  • 4db1495 Merge hr/main; renumber scheduled-tick hook to API 34

📊 Changes

7 files changed (+221 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+25 -5)
📝 crates/horizon-world/src/level/mod.rs (+14 -0)
📝 crates/horizon-world/src/level/tests.rs (+135 -0)
📝 crates/horizon-world/src/level/tick.rs (+15 -2)
📝 docs/native-mods.md (+11 -1)
📝 native-hooks.json (+5 -0)

📄 Description

What and why

A native mod can't act on its blocks' scheduled ticks yet (a block that changes a moment after it's placed or powered)

native_tick_block fires for each due scheduled tick of a block that is still there, where ServerLevel.tickBlock calls BlockState.tick
Same contract as native_random_tick (#4872): change the block with native_set_block_property and the flags vanilla's block would use (an observer writes with 2, a target block with UPDATE_ALL), set handled to skip the block's own tick
If it changes the block without handled, the block ticks as it is now, if it's still the tick's block

Server side only, both ways the game runs scheduled ticks reach it
Chunk post-processing's liquid ticks don't, they aren't tickBlock

Without a mod scheduled_step is the same code as on main in an optimized build
With a mod that handles its block it's about 0.4 µs a tick more than vanilla's own write

Stacked on #4872 (the level helper), review only the last commit
This bumps the hook points API to 24 (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

ServerLevel.tickBlock (reads the state, state.is(block), then tick)

Self-check

The scope counts #4872 below, this commit alone is +232 −20
The one failure is a_candle_on_an_uneaten_cake_makes_a_candle_cake (#4780)

Check Result
Scope ⚠️ 7 files, +511 −17; 501 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (56 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 26 s)
tests: horizon-client, horizon-world ❌ 1471 passed, 1 failed (7 min 20 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/4880 **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-scheduled-tick` --- ### 📝 Commits (2) - [`6521dff`](https://github.com/horizon-rust/horizon/commit/6521dffceed538fa989a93bdadf06cafa7891b8f) feat(mods): native mods can change their blocks on scheduled ticks - [`4db1495`](https://github.com/horizon-rust/horizon/commit/4db1495bfb0d32b81820ef705cac2fcc87f51a81) Merge hr/main; renumber scheduled-tick hook to API 34 ### 📊 Changes **7 files changed** (+221 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+25 -5) 📝 `crates/horizon-world/src/level/mod.rs` (+14 -0) 📝 `crates/horizon-world/src/level/tests.rs` (+135 -0) 📝 `crates/horizon-world/src/level/tick.rs` (+15 -2) 📝 `docs/native-mods.md` (+11 -1) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description ## What and why A native mod can't act on its blocks' scheduled ticks yet (a block that changes a moment after it's placed or powered) `native_tick_block` fires for each due scheduled tick of a block that is still there, where `ServerLevel.tickBlock` calls `BlockState.tick` Same contract as `native_random_tick` (#4872): change the block with `native_set_block_property` and the flags vanilla's block would use (an observer writes with 2, a target block with `UPDATE_ALL`), set `handled` to skip the block's own tick If it changes the block without `handled`, the block ticks as it is now, if it's still the tick's block Server side only, both ways the game runs scheduled ticks reach it Chunk post-processing's liquid ticks don't, they aren't `tickBlock` Without a mod `scheduled_step` is the same code as on main in an optimized build With a mod that handles its block it's about 0.4 µs a tick more than vanilla's own write Stacked on #4872 (the level helper), review only the last commit This bumps the hook points API to 24 (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 `ServerLevel.tickBlock` (reads the state, `state.is(block)`, then `tick`) ## Self-check The scope counts #4872 below, this commit alone is +232 −20 The one failure is `a_candle_on_an_uneaten_cake_makes_a_candle_cake` (#4780) | Check | Result | | --- | --- | | Scope | ⚠️ 7 files, +511 −17; 501 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (56 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 26 s) | | tests: horizon-client, horizon-world | ❌ 1471 passed, 1 failed (7 min 20 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:52 +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#5913
No description provided.