[PR #5527] [MERGED] Native mods: bone meal on a mod block #6338

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5527
Author: @sirrayi
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: mods/bone-meal-on-mod-blocks


📝 Commits (3)

  • 0be8029 Native mods: bone meal on a mod block
  • 0ddaee3 Native hooks: a villager bonemeals a mod block only when it is a crop
  • 06584db Bone meal hook: a mod's no keeps the meal, as vanilla's growCrop does

📊 Changes

8 files changed (+314 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+19 -0)
📝 crates/horizon-client/src/game/level_particles.rs (+7 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+69 -0)
📝 crates/horizon-client/src/game/remote.rs (+10 -0)
📝 crates/horizon-world/src/level/bonemeal.rs (+24 -1)
📝 crates/horizon-world/src/level/growth_tests.rs (+142 -0)
📝 crates/horizon-world/src/level/mod.rs (+25 -0)
➕ tools/native-hook-fragments/bonemeal.json (+18 -0)

📄 Description

🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally.

Closes #5488. Part of #4953, under Mod block behaviour ("whether a block can stay where it is, bone meal, and the state it is placed in").

What and why

A mod block took no bone meal: BoneMealItem.growCrop looked the block's BonemealableBlock up among the port's classes and stopped there. The level now answers vanilla's three questions for it, ahead of the BonemealableBlock a content template would have given it:

// The hooks a bundle injects (crates/horizon-client/src/game/native_hooks.rs).
pub(super) fn native_is_valid_bonemeal_target(&self, dimension, pos, state, valid: &mut bool);
pub(super) fn native_is_bonemeal_success(&mut self, dimension, pos, state, success: &mut bool);
pub(super) fn native_perform_bonemeal(&mut self, ticks: &mut Ticks, dimension, pos, state);
  • isValidBonemealTarget: valid for your own blocks. Asked on both sides, as vanilla asks it — a client predicts the use with the mod's own answer — so a mod that can only grow on a server says no with is_client_side. A block that says no keeps the BonemealableBlock its template gives it, or takes no bone meal.
  • isBonemealSuccess: whether it grows this time. Vanilla draws Level.random here, so native_level_random() is the level's own stream (the same one native_level_random(dimension) hands a server hook), and the mod's draws shift vanilla's as a Java mod's would.
  • performBonemeal: the growth, with the level's ticks (so native_set_block_property and native_schedule_block_tick work as from any world hook).

One insertion point, every placer

Sim::grow_crop (crates/horizon-world/src/level/bonemeal.rs) is where all three of the issue's placers meet — the player's BoneMealItem.useOn (Behaviours::use_bone_meal), a dispenser's BoneMealItem.growCrop (dispense_bone_meal), and a villager's bone meal — so the hook runs for each of them, not only the player. The callers do the rest unchanged, which is exactly what the issue asks for:

  • the meal used up: grow_crop returning true makes Game::use_bone_meal consume the stack (and dispense_bone_meal shrink its slot), as it does for vanilla's blocks, and the roll failing still consumes it, as vanilla does;
  • the particles: the same callers fire level event 1505, which the client turns into growth_particles and minecraft:item.bone_meal.use.

A mod block's own growth particles were the one place the port still had no answer for it (Behaviours::bone_meal_spreads returns None for a block with no BonemealableBlock.Type), so growth_particles now treats a non-minecraft block with no known type as vanilla's GROWER: sparks inside the block rather than over its neighbours. Vanilla blocks keep the type the port knows.

The client's copy of the level (DryLevel, crates/horizon-client/src/game/remote.rs) forwards the one read-only question, so remote_bone_meal_succeeds — the prediction a window or a LAN guest makes — agrees with the server.

Vanilla reference

BoneMealItem.useOn/growCrop, BonemealableBlock.isValidBonemealTarget/isBonemealSuccess/performBonemeal, BonemealableBlock.Type (GROWER, NEIGHBOR_SPREADER), LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH (1505), ParticleUtils.spawnParticleInBlock, ShulkerBoxDispenseBehavior's neighbour (DispenserBlock bone meal), Villager's bone meal goal. NeoForge's BonemealEvent is why the three answers stay three hooks rather than one. No decompiled sources on this machine (no .local/), so the port's bonemeal.rs, which already follows those methods, was the reference. Harnesses: tools/test_dispenser_parity.py (the dispenser's bone meal) and tools/test_use_item_on_parity.py (a player's) cover vanilla's and are unaffected: the hook answers nothing for a vanilla block, so the same classes, the same draws and the same level event run.

Other projects' code

None.

Kind

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

A native hook is feature like #5469 (mods' own sound events); players see nothing until a mod uses it, so skip-release may suit the maintainer better — their call.

Self-check

pr_ready (tools/pr_ready.py --quick on MacBookPro, against origin/main at 21bddafb2, 3 min 27 s)

Check Result
Scope ✅ 8 files, +288 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 487 run, FAILED (errors=13, skipped=1) (58 s)
rustfmt ✅ (8 s)
clippy ✅ (1 min 1 s)
tests: horizon-client, horizon-world ✅ 1924 passed (1 min 17 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)

The 13 Python errors are this machine's Python 3.9, not this change: tools/lab.py digests with hashlib.file_digest, which arrived in 3.11 (test_lab, test_parity_runner, test_rust_parity, test_block_survival_parity, test_roadmap). No Python file is touched here.

Tests

bone_meal_answers_a_mod_blocks_three_questions (crates/horizon-world/src/level/growth_tests.rs) — a LevelAccess whose three answers are the test's:

  • a block nothing bonemeals (stone) is a target: the meal is used, the roll runs, performBonemeal is handed the position and the block's state, and use_bone_meal reports level event 1505 there (the growth particles and sound);

  • a failing roll still uses the meal up and grows nothing;

  • a refused block takes no meal: no roll, no growth, use_bone_meal false;

  • a block whose template bonemeals (a wheat[age=0]) is the mod's: its own growth does not run, and answered nothing it keeps its own and grows;

  • a client predicts the use with the same answer where the block itself takes no bone meal on a client.

  • Not run locally: it needs the prepared vanilla data (HORIZON_RESOURCES, or .local/horizon-client/26.3), which this machine does not have, so it passes CI only and skips locally like every other test in that file (growth_tests.rs skips without worldgen/blocks/block-properties.nbt too). The rest ran here: cargo test -p horizon-world --lib (267), cargo test -p horizon-client --lib --bins, cargo clippy -p horizon-world -p horizon-client --all-targets, cargo fmt --all -- --check.

  • Not tested in game: no prepared resources on this machine, so no server-thread run and no screenshot.

API

Pending fragment tools/native-hook-fragments/bonemeal.json (hooks is_valid_bonemeal_target, is_bonemeal_success, perform_bonemeal, v1) plus the helper native_level_random, as #5161 asks: no number is taken here.

🤖 Generated with DeepSeek Harness (deepseek-v4.1-flash)


🔄 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/5527 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `mods/bone-meal-on-mod-blocks` --- ### 📝 Commits (3) - [`0be8029`](https://github.com/horizon-rust/horizon/commit/0be8029be85a881d09e5839c03ba1cfffa3e61cf) Native mods: bone meal on a mod block - [`0ddaee3`](https://github.com/horizon-rust/horizon/commit/0ddaee3da8353e911a70fb635d80fac8ea6b272f) Native hooks: a villager bonemeals a mod block only when it is a crop - [`06584db`](https://github.com/horizon-rust/horizon/commit/06584db0097fa7ac20f0b7190e0d68cc800b6e51) Bone meal hook: a mod's no keeps the meal, as vanilla's growCrop does ### 📊 Changes **8 files changed** (+314 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+19 -0) 📝 `crates/horizon-client/src/game/level_particles.rs` (+7 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+69 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+10 -0) 📝 `crates/horizon-world/src/level/bonemeal.rs` (+24 -1) 📝 `crates/horizon-world/src/level/growth_tests.rs` (+142 -0) 📝 `crates/horizon-world/src/level/mod.rs` (+25 -0) ➕ `tools/native-hook-fragments/bonemeal.json` (+18 -0) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. Closes #5488. Part of #4953, under **Mod block behaviour** ("whether a block can stay where it is, bone meal, and the state it is placed in"). ## What and why A mod block took no bone meal: `BoneMealItem.growCrop` looked the block's `BonemealableBlock` up among the port's classes and stopped there. The level now answers vanilla's three questions for it, ahead of the `BonemealableBlock` a content template would have given it: ```rust // The hooks a bundle injects (crates/horizon-client/src/game/native_hooks.rs). pub(super) fn native_is_valid_bonemeal_target(&self, dimension, pos, state, valid: &mut bool); pub(super) fn native_is_bonemeal_success(&mut self, dimension, pos, state, success: &mut bool); pub(super) fn native_perform_bonemeal(&mut self, ticks: &mut Ticks, dimension, pos, state); ``` - `isValidBonemealTarget`: `valid` for your own blocks. Asked on **both sides**, as vanilla asks it — a client predicts the use with the mod's own answer — so a mod that can only grow on a server says no with `is_client_side`. A block that says no keeps the `BonemealableBlock` its template gives it, or takes no bone meal. - `isBonemealSuccess`: whether it grows this time. Vanilla draws `Level.random` here, so `native_level_random()` is the level's own stream (the same one `native_level_random(dimension)` hands a server hook), and the mod's draws shift vanilla's as a Java mod's would. - `performBonemeal`: the growth, with the level's ticks (so `native_set_block_property` and `native_schedule_block_tick` work as from any world hook). ## One insertion point, every placer `Sim::grow_crop` (`crates/horizon-world/src/level/bonemeal.rs`) is where all three of the issue's placers meet — the player's `BoneMealItem.useOn` (`Behaviours::use_bone_meal`), a dispenser's `BoneMealItem.growCrop` (`dispense_bone_meal`), and a villager's bone meal — so the hook runs for each of them, not only the player. The callers do the rest unchanged, which is exactly what the issue asks for: - **the meal used up**: `grow_crop` returning true makes `Game::use_bone_meal` consume the stack (and `dispense_bone_meal` shrink its slot), as it does for vanilla's blocks, and the roll failing still consumes it, as vanilla does; - **the particles**: the same callers fire level event 1505, which the client turns into `growth_particles` and `minecraft:item.bone_meal.use`. A mod block's own growth particles were the one place the port still had no answer for it (`Behaviours::bone_meal_spreads` returns `None` for a block with no `BonemealableBlock.Type`), so `growth_particles` now treats a non-`minecraft` block with no known type as vanilla's `GROWER`: sparks inside the block rather than over its neighbours. Vanilla blocks keep the type the port knows. The client's copy of the level (`DryLevel`, `crates/horizon-client/src/game/remote.rs`) forwards the one read-only question, so `remote_bone_meal_succeeds` — the prediction a window or a LAN guest makes — agrees with the server. ## Vanilla reference `BoneMealItem.useOn`/`growCrop`, `BonemealableBlock.isValidBonemealTarget`/`isBonemealSuccess`/`performBonemeal`, `BonemealableBlock.Type` (`GROWER`, `NEIGHBOR_SPREADER`), `LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH` (1505), `ParticleUtils.spawnParticleInBlock`, `ShulkerBoxDispenseBehavior`'s neighbour (`DispenserBlock` bone meal), `Villager`'s bone meal goal. NeoForge's `BonemealEvent` is why the three answers stay three hooks rather than one. No decompiled sources on this machine (no `.local/`), so the port's `bonemeal.rs`, which already follows those methods, was the reference. Harnesses: `tools/test_dispenser_parity.py` (the dispenser's bone meal) and `tools/test_use_item_on_parity.py` (a player's) cover vanilla's and are unaffected: the hook answers nothing for a vanilla block, so the same classes, the same draws and the same level event run. ## Other projects' code None. ## Kind - [x] feature: something new for players - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs A native hook is `feature` like #5469 (mods' own sound events); players see nothing until a mod uses it, so `skip-release` may suit the maintainer better — their call. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at 21bddafb2, 3 min 27 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +288 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 487 run, FAILED (errors=13, skipped=1) (58 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (1 min 1 s) | | tests: horizon-client, horizon-world | ✅ 1924 passed (1 min 17 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) | The 13 Python errors are this machine's Python 3.9, not this change: `tools/lab.py` digests with `hashlib.file_digest`, which arrived in 3.11 (`test_lab`, `test_parity_runner`, `test_rust_parity`, `test_block_survival_parity`, `test_roadmap`). No Python file is touched here. ## Tests `bone_meal_answers_a_mod_blocks_three_questions` (`crates/horizon-world/src/level/growth_tests.rs`) — a `LevelAccess` whose three answers are the test's: - a block nothing bonemeals (stone) is a target: the meal is used, the roll runs, `performBonemeal` is handed the position and the block's state, and `use_bone_meal` reports level event 1505 there (the growth particles and sound); - a failing roll still uses the meal up and grows nothing; - a refused block takes no meal: no roll, no growth, `use_bone_meal` false; - a block whose template bonemeals (a `wheat[age=0]`) is the mod's: its own growth does not run, and answered nothing it keeps its own and grows; - a client predicts the use with the same answer where the block itself takes no bone meal on a client. - **Not run locally:** it needs the prepared vanilla data (`HORIZON_RESOURCES`, or `.local/horizon-client/26.3`), which this machine does not have, so it passes CI only and skips locally like every other test in that file (`growth_tests.rs` skips without `worldgen/blocks/block-properties.nbt` too). The rest ran here: `cargo test -p horizon-world --lib` (267), `cargo test -p horizon-client --lib --bins`, `cargo clippy -p horizon-world -p horizon-client --all-targets`, `cargo fmt --all -- --check`. - **Not tested in game:** no prepared resources on this machine, so no server-thread run and no screenshot. ## API Pending fragment `tools/native-hook-fragments/bonemeal.json` (hooks `is_valid_bonemeal_target`, `is_bonemeal_success`, `perform_bonemeal`, v1) plus the helper `native_level_random`, as #5161 asks: no number is taken here. 🤖 Generated with DeepSeek Harness (deepseek-v4.1-flash) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:18:32 +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#6338
No description provided.