[PR #80] [MERGED] Composters take compostable items by hand, from hoppers and from droppers #2311

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/80
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/composters-70


📝 Commits (1)

  • 0d3628a Composters take compostable items by hand, from hoppers and from droppers

📊 Changes

10 files changed (+531 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+10 -0)
📝 crates/horizon-client/src/game/commands.rs (+1 -1)
➕ crates/horizon-client/src/game/composter.rs (+122 -0)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+63 -0)
📝 crates/horizon-client/src/game/machines.rs (+62 -2)
📝 crates/horizon-client/src/items.rs (+3 -0)
📝 crates/horizon-world/src/level/interact.rs (+51 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java (+5 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java (+59 -0)
➕ tools/test_composter_parity.py (+155 -0)

📄 Description

What was wrong

Right-clicking a composter with wheat or any other compostable item did nothing (#70). Horizon only implemented ComposterBlock.useWithoutItem, which empties a full composter. useItemOn was missing, so the item went on to its own use (or nowhere). Hoppers and droppers didn't treat the composter as a container either, and a hopper under a composter sucked dropped items straight through it.

What vanilla does (26.3)

  • ComposterBlock.useItemOn: with an item carrying the compostable data component and a level below 8, the action is consumed (SUCCESS). Below level 7, addLayer evaluates the component's layers provider (ContextIntProviders.COMPOSTABLE_*: a number_dispatcher that always adds a layer to an empty composter, else a weighted 1/0 list drawn from the level random) in a block-interaction loot context. It then sets the new level (setBlockAndUpdate, BLOCK_CHANGE game event, a 20-tick scheduled tick at level 7), fires level event 1500 (data 1 when a layer was added), awards minecraft.used and consumes one item (ItemStack.consume: none in creative). A full composter returns TRY_WITH_EMPTY_HAND, so useWithoutItem empties it.
  • ComposterBlock.handleFill (level event 1500, client): block.composter.fill_success / fill and ten composter particles above the compost surface.
  • WorldlyContainerHolder.getContainer, used by HopperBlockEntity.getContainerAt (hoppers, droppers, crafters):
    • InputContainer (levels 0–6) takes one compostable item from above, and its setChanged composts it right away.
    • EmptyContainer at level 7 takes nothing.
    • OutputContainer at level 8 gives a hopper below its bone meal. Both removeItem and the second setChanged (or the setItem that puts the bone meal back when the hopper is full) call empty(), so there are two BLOCK_CHANGE events, and the bone meal is lost when the hopper has no room.
    • A non-null container also stops a hopper from sucking item entities above.

The fix

  • game/composter.rs: use_composter (useItemOn, hooked in right before useWithoutItem in use_item_as_player), composter_container_insert (the input container), and composter_fill_event (level event 1500). Layers are evaluated with the existing context-provider evaluator (/compute's provider_int, match_block on the composter's state, the level random).
  • horizon-world: Behaviours::composter_insert (addLayer + level event 1500) and composter_empty.
  • machines.rs: composters are Kind::Composter(level) containers with the vanilla faces, input/output rules and the double empty. Comparators keep reading the block's analog output.
  • items.rs: ItemInfo::compostable.

Tests

tools/test_composter_parity.py (new) runs one action per case on a composter at a random level through VanillaDispenserOracle (new use and hopper actions; use drives a stand-in ServerPlayer through useItemOn then useWithoutItem) and the game's dispense fixture:

  • right-clicks with compostable items, other items or nothing, in survival and creative;
  • hoppers above facing down or sideways;
  • hoppers below, sometimes full or holding bone meal;
  • droppers facing into composters.

It compares block changes, container contents, spawned items, level events and their sounds, sounds, game events, statistics, the held stack and the final level random. The oracle's stand-in loot holder now answers lookup(), which loot contexts need to resolve providers.

  • 1500/1500 cases match.
  • With useItemOn disabled (the old behaviour), 237/300 match and all 63 failures are right-clicks.
  • On the Mac mini: tools/parity.py composter dispenser crafter block_removal block_update random_tick redstone menu_click → 8 passed.
  • cargo clippy --workspace --all-targets -D warnings, cargo test -p horizon-client -p horizon-world and tools/check_public_tree.py pass.

Not covered here: minecart hoppers still only pick up item entities (they never pull from containers above, composters included), and farmer villagers don't compost yet.

Fixes #70

🤖 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/80 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/composters-70` --- ### 📝 Commits (1) - [`0d3628a`](https://github.com/horizon-rust/horizon/commit/0d3628a0350e6055c0fa7b52fafb92d45312d67f) Composters take compostable items by hand, from hoppers and from droppers ### 📊 Changes **10 files changed** (+531 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+10 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) ➕ `crates/horizon-client/src/game/composter.rs` (+122 -0) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+63 -0) 📝 `crates/horizon-client/src/game/machines.rs` (+62 -2) 📝 `crates/horizon-client/src/items.rs` (+3 -0) 📝 `crates/horizon-world/src/level/interact.rs` (+51 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java` (+5 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java` (+59 -0) ➕ `tools/test_composter_parity.py` (+155 -0) </details> ### 📄 Description ## What was wrong Right-clicking a composter with wheat or any other compostable item did nothing (#70). Horizon only implemented `ComposterBlock.useWithoutItem`, which empties a full composter. `useItemOn` was missing, so the item went on to its own use (or nowhere). Hoppers and droppers didn't treat the composter as a container either, and a hopper under a composter sucked dropped items straight through it. ## What vanilla does (26.3) - `ComposterBlock.useItemOn`: with an item carrying the `compostable` data component and a level below 8, the action is consumed (SUCCESS). Below level 7, `addLayer` evaluates the component's `layers` provider (`ContextIntProviders.COMPOSTABLE_*`: a `number_dispatcher` that always adds a layer to an empty composter, else a weighted 1/0 list drawn from the level random) in a block-interaction loot context. It then sets the new level (`setBlockAndUpdate`, BLOCK_CHANGE game event, a 20-tick scheduled tick at level 7), fires level event 1500 (data 1 when a layer was added), awards `minecraft.used` and consumes one item (`ItemStack.consume`: none in creative). A full composter returns `TRY_WITH_EMPTY_HAND`, so `useWithoutItem` empties it. - `ComposterBlock.handleFill` (level event 1500, client): `block.composter.fill_success` / `fill` and ten `composter` particles above the compost surface. - `WorldlyContainerHolder.getContainer`, used by `HopperBlockEntity.getContainerAt` (hoppers, droppers, crafters): - `InputContainer` (levels 0–6) takes one compostable item from above, and its `setChanged` composts it right away. - `EmptyContainer` at level 7 takes nothing. - `OutputContainer` at level 8 gives a hopper below its bone meal. Both `removeItem` and the second `setChanged` (or the `setItem` that puts the bone meal back when the hopper is full) call `empty()`, so there are two BLOCK_CHANGE events, and the bone meal is lost when the hopper has no room. - A non-null container also stops a hopper from sucking item entities above. ## The fix - `game/composter.rs`: `use_composter` (useItemOn, hooked in right before `useWithoutItem` in `use_item_as_player`), `composter_container_insert` (the input container), and `composter_fill_event` (level event 1500). Layers are evaluated with the existing context-provider evaluator (`/compute`'s `provider_int`, `match_block` on the composter's state, the level random). - horizon-world: `Behaviours::composter_insert` (addLayer + level event 1500) and `composter_empty`. - `machines.rs`: composters are `Kind::Composter(level)` containers with the vanilla faces, input/output rules and the double empty. Comparators keep reading the block's analog output. - `items.rs`: `ItemInfo::compostable`. ## Tests `tools/test_composter_parity.py` (new) runs one action per case on a composter at a random level through `VanillaDispenserOracle` (new `use` and `hopper` actions; `use` drives a stand-in `ServerPlayer` through `useItemOn` then `useWithoutItem`) and the game's dispense fixture: - right-clicks with compostable items, other items or nothing, in survival and creative; - hoppers above facing down or sideways; - hoppers below, sometimes full or holding bone meal; - droppers facing into composters. It compares block changes, container contents, spawned items, level events and their sounds, sounds, game events, statistics, the held stack and the final level random. The oracle's stand-in loot holder now answers `lookup()`, which loot contexts need to resolve providers. - 1500/1500 cases match. - With `useItemOn` disabled (the old behaviour), 237/300 match and all 63 failures are right-clicks. - On the Mac mini: `tools/parity.py composter dispenser crafter block_removal block_update random_tick redstone menu_click` → 8 passed. - `cargo clippy --workspace --all-targets -D warnings`, `cargo test -p horizon-client -p horizon-world` and `tools/check_public_tree.py` pass. Not covered here: minecart hoppers still only pick up item entities (they never pull from containers above, composters included), and farmer villagers don't compost yet. Fixes #70 🤖 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-02 15:54: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#2311
No description provided.