[PR #6167] [MERGED] feat(mods): a content block's random_ticks property #6691

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6167
Author: @Xmilon
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/mod-random-ticks


📝 Commits (2)

  • 9697811 feat(mods): a content block's random_ticks property
  • 5d08602 Mod registry: refresh its Cargo.lock for horizon-mods' png dependency

📊 Changes

5 files changed (+132 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/mod_content.rs (+5 -2)
📝 crates/horizon-client/src/mod_content_tests.rs (+8 -1)
📝 crates/horizon-mod-registry/Cargo.lock (+34 -1)
📝 crates/horizon-mods/src/content.rs (+78 -0)
📝 docs/mods.md (+7 -0)

📄 Description

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

What and why

Fixes #6138. Part of #4953.

A mod block only got random ticks when its template ticks, so a crop, sapling or soil on a template that never ticks (dirt, stone) never grew on its own. Vanilla asks BlockBehaviour.isRandomlyTicking(state) per state, and a mod block overrides it for its own states.

A block's properties get a random_ticks key:

{ "template": "minecraft:dirt", "properties": { "random_ticks": true } }

or, for the states whose own state property (declared in state_properties) is one of the values, e.g. a crop that stops ticking once grown:

{ "template": "minecraft:dirt",
  "state_properties": { "grown": { "type": "boolean" } },
  "properties": { "random_ticks": { "property": "grown", "values": ["false"] } } }

false stops a template that does tick. The key sets the state's random_ticks flag in its gameplay row, which isRandomlyTicking, the sections' random tick counts (random_tick_candidate) and native_random_tick already read, so no ticking code changes: the hook fires for these states as it does for a vanilla block that ticks.

A random_ticks property that is not the block's own state property, has no values, or names a value it doesn't have is refused when the content is read. Documented in docs/mods.md.

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

BlockBehaviour.isRandomlyTicking(BlockState), LevelChunkSection.isRandomlyTicking (the section's count). Horizon-only content-mod key.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on T90, against upstream/main at 975c07d91, 12 min 21 s)

Check Result
Scope ✅ 4 files, +98 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 586 passed (2 min 33 s)
rustfmt ✅ (14 s)
clippy ✅ (2 min 2 s)
tests: horizon-client, horizon-mods ❌ failed (2 min 39 s)
doc tests ✅ 0 passed (4 s)
content root tests ✅ 20 passed (50 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (1 min 31 s)
launcher tests ✅ 377 passed (2 min 21 s)
Parity ➖ not run (no vanilla data here): 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 one ❌ is not a failing test: rustc itself crashed (STATUS_STACK_BUFFER_OVERRUN, in collect_and_partition_mono_items) while compiling the horizon-client test targets in debug on this Windows machine, so those tests did not run here; CI's verify runs them. The content root tests row did not really run: those tests return early when the prepared game resources are not next to the checkout, so its "20 passed" is empty. Run for real with the resources linked, content_root_loads_with_every_table passes (78 s), including the new random_ticks assertions.

  • New unit test blocks_pick_the_states_that_tick_randomly (horizon-mods): every state, false, chosen states by the block's own property, a state without the property, and the refused cases.
  • The content-root test (content_root_loads_with_every_table) now has ruby_block with random_ticks: true on an iron template and asserts is_randomly_ticking, random_tick_candidate, and that iron itself still does not tick.
  • Not tested in game.

🤖 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/6167 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/mod-random-ticks` --- ### 📝 Commits (2) - [`9697811`](https://github.com/horizon-rust/horizon/commit/9697811a90fb467339d052f31bc5d33ddc062d9f) feat(mods): a content block's `random_ticks` property - [`5d08602`](https://github.com/horizon-rust/horizon/commit/5d08602df3d6d1d8ff230c73414e50d4d27c3635) Mod registry: refresh its Cargo.lock for horizon-mods' png dependency ### 📊 Changes **5 files changed** (+132 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mod_content.rs` (+5 -2) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+8 -1) 📝 `crates/horizon-mod-registry/Cargo.lock` (+34 -1) 📝 `crates/horizon-mods/src/content.rs` (+78 -0) 📝 `docs/mods.md` (+7 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Claude Code, Claude Opus 5.5), not by Xmilon personally. ## What and why Fixes #6138. Part of #4953. A mod block only got random ticks when its template ticks, so a crop, sapling or soil on a template that never ticks (`dirt`, `stone`) never grew on its own. Vanilla asks `BlockBehaviour.isRandomlyTicking(state)` per state, and a mod block overrides it for its own states. A block's `properties` get a `random_ticks` key: ```json { "template": "minecraft:dirt", "properties": { "random_ticks": true } } ``` or, for the states whose own state property (declared in `state_properties`) is one of the values, e.g. a crop that stops ticking once grown: ```json { "template": "minecraft:dirt", "state_properties": { "grown": { "type": "boolean" } }, "properties": { "random_ticks": { "property": "grown", "values": ["false"] } } } ``` `false` stops a template that does tick. The key sets the state's `random_ticks` flag in its gameplay row, which `isRandomlyTicking`, the sections' random tick counts (`random_tick_candidate`) and `native_random_tick` already read, so no ticking code changes: the hook fires for these states as it does for a vanilla block that ticks. A `random_ticks` property that is not the block's own state property, has no values, or names a value it doesn't have is refused when the content is read. Documented in `docs/mods.md`. ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference `BlockBehaviour.isRandomlyTicking(BlockState)`, `LevelChunkSection.isRandomlyTicking` (the section's count). Horizon-only content-mod key. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on T90, against upstream/main at 975c07d91, 12 min 21 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +98 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 586 passed (2 min 33 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (2 min 2 s) | | tests: horizon-client, horizon-mods | ❌ failed (2 min 39 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ✅ 20 passed (50 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (1 min 31 s) | | launcher tests | ✅ 377 passed (2 min 21 s) | | Parity | ➖ not run (no vanilla data here): 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 one ❌ is not a failing test: rustc itself crashed (`STATUS_STACK_BUFFER_OVERRUN`, in `collect_and_partition_mono_items`) while compiling the `horizon-client` test targets in debug on this Windows machine, so those tests did not run here; CI's `verify` runs them. The `content root tests` row did not really run: those tests return early when the prepared game resources are not next to the checkout, so its "20 passed" is empty. Run for real with the resources linked, `content_root_loads_with_every_table` passes (78 s), including the new `random_ticks` assertions. - New unit test `blocks_pick_the_states_that_tick_randomly` (horizon-mods): every state, `false`, chosen states by the block's own property, a state without the property, and the refused cases. - The content-root test (`content_root_loads_with_every_table`) now has `ruby_block` with `random_ticks: true` on an iron template and asserts `is_randomly_ticking`, `random_tick_candidate`, and that iron itself still does not tick. - Not tested in game. 🤖 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:24:57 +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#6691
No description provided.