[PR #799] [MERGED] fix(game): finish every consumable as vanilla's Consumable.onConsume (milk, honey, chorus fruit) #2821

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

📋 Pull Request Information

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

Base: main ← Head: fix/consume-effects-vanilla


📝 Commits (2)

  • 118bfa2 fix(game): finish every consumable as vanilla's Consumable.onConsume
  • 20fada2 Rerun CI now that the PR is ready for review

📊 Changes

8 files changed (+568 additions, -82 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+51 -54)
➕ crates/horizon-client/src/game/consume.rs (+330 -0)
📝 crates/horizon-client/src/game/level_particles.rs (+9 -3)
📝 crates/horizon-client/src/game/remote.rs (+12 -7)
📝 crates/horizon-client/src/items.rs (+81 -8)
📝 crates/horizon-client/src/motion.rs (+2 -1)
📝 crates/horizon-client/src/particles.rs (+35 -7)
📝 tools/agent_control_e2e.py (+48 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Follow-up to lazy-importer's #773 (always-edible food and consume effects, merged): every consumable now finishes the way vanilla 26.3's Consumable.onConsume does. #773's code stays as it is, apart from the fixes below.

  • ApplyStatusEffectsConsumeEffect: the float is always drawn, even at probability 1, and the effects are skipped when the draw is >= probability. #773 skipped the draw at 1.0 and applied the effects on <=. Horizon's player has no random of its own: the level random stands in for user.getRandom(), as it already does for the eating sounds, the item particles and every other player draw.

  • Consumables without food: on_consume_effects now run for every consumable. Milk can be drunk (clear_all_effects, which no other code path applied, so effects aren't cleared twice), and honey removes poison. UseRemainder hands back the bucket, glass bottle or bowl: in the hand when the stack runs out, otherwise into the inventory, or dropped when the inventory is full. Creative leaves the stack alone.

  • The consumable's own style: consume_seconds (dried kelp 16 ticks, honey 40), sound (drink and honey sounds), animation (eat or drink game event) and has_consume_particles, all emitted through horizon-world's parity-tested Consumable.emit in vanilla's draw order. Before this, the volume was inverted (nextInt(2) against nextBoolean) and the randomBetween draw was missing. Also added: FoodProperties.onConsume's consume sound before the burp, the used statistic, and the game event after the effects (so chorus fruit's eat event comes from where you land).

  • teleport_randomly (chorus fruit): runs through horizon-world's verified TeleportConsume port (tools/test_teleport_consume_parity.py), which keeps vanilla's 16 attempts and its draws in order. For the player this PR adds LivingEntity.randomTeleport / checkPositionAndTeleport:

    • the world-border clamp and the loaded-chunk check;
    • the drop down to entities_can_teleport_to ground;
    • the player's box clear of blocks, entity boxes and liquid;
    • the consumable_does_not_teleport_to tag.

    On success: dismount (stopRiding), the teleport game event, the chorus sound, level event 2017's directional particles (also handled when a server sends them), entity event 46's portal particles, and the fall distance and impulse context reset.

  • remote.rs: the server-client eating animation from #787 reads the consumable's duration and particle flag instead of a fixed 32 ticks.

Not in this PR

  • Chorus fruit's 1 s use_cooldown: Horizon has no item cooldowns yet (ender pearls don't have one either).
  • Level.noCollision's world-border shape, in the teleport's collision check (the border clamp covers the centre).

How tested

Check Result
cargo fmt --all ✅
cargo clippy -p horizon-client --all-targets -- -D warnings ✅
cargo test -p horizon-client ✅ every suite (844 + 66 + 22 tests)
tools/agent_control_e2e.py --scenario consume (new: golden apple at full hunger, milk, honey, chorus fruit) ✅ cli and mcp (teleported [4.66, 0, 7.65] and [-7.44, 0, 2.45])
tools/parity.py --changed origin/main (89 harnesses) ✅ the harnesses covering the changed code: particle_providers, emitter_particles, entity_particles, first_person, use_item_on, sculk, hotbar, game_loop, sound_event (9/9), plus ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_particles, block_removal, block_transformer from the full --changed set before it was stopped. The full set (89 harnesses: every one with a horizon-client probe) would take hours on the busy Mac mini; CI runs the rest.

New unit tests: items::tests::always_edible_and_consume_effects_loaded (extended to cover milk, honey, dried kelp, chorus and chicken: timing, sound, animation, particles, remainders, effects) and particles::tests::consume_teleport_unpacks_offsets_within_127. On main, milk can't be drunk at all (start_eating required food), so the consume scenario fails there at its milk step.

Needs Ludovic

Nothing to decide here.

🤖 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/799 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/consume-effects-vanilla` --- ### 📝 Commits (2) - [`118bfa2`](https://github.com/horizon-rust/horizon/commit/118bfa2be2a9cf85961fdccfa6d9afca117aedf3) fix(game): finish every consumable as vanilla's Consumable.onConsume - [`20fada2`](https://github.com/horizon-rust/horizon/commit/20fada25bd4bdc62465dd09160862049c9a1d2fd) Rerun CI now that the PR is ready for review ### 📊 Changes **8 files changed** (+568 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+51 -54) ➕ `crates/horizon-client/src/game/consume.rs` (+330 -0) 📝 `crates/horizon-client/src/game/level_particles.rs` (+9 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+12 -7) 📝 `crates/horizon-client/src/items.rs` (+81 -8) 📝 `crates/horizon-client/src/motion.rs` (+2 -1) 📝 `crates/horizon-client/src/particles.rs` (+35 -7) 📝 `tools/agent_control_e2e.py` (+48 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Follow-up to lazy-importer's #773 (always-edible food and consume effects, merged): every consumable now finishes the way vanilla 26.3's `Consumable.onConsume` does. #773's code stays as it is, apart from the fixes below. - **`ApplyStatusEffectsConsumeEffect`**: the float is always drawn, even at probability 1, and the effects are skipped when the draw is `>= probability`. #773 skipped the draw at 1.0 and applied the effects on `<=`. Horizon's player has no random of its own: the level random stands in for `user.getRandom()`, as it already does for the eating sounds, the item particles and every other player draw. - **Consumables without food**: `on_consume_effects` now run for every consumable. Milk can be drunk (`clear_all_effects`, which no other code path applied, so effects aren't cleared twice), and honey removes poison. `UseRemainder` hands back the bucket, glass bottle or bowl: in the hand when the stack runs out, otherwise into the inventory, or dropped when the inventory is full. Creative leaves the stack alone. - **The consumable's own style**: `consume_seconds` (dried kelp 16 ticks, honey 40), `sound` (drink and honey sounds), `animation` (eat or drink game event) and `has_consume_particles`, all emitted through horizon-world's parity-tested `Consumable.emit` in vanilla's draw order. Before this, the volume was inverted (`nextInt(2)` against `nextBoolean`) and the `randomBetween` draw was missing. Also added: `FoodProperties.onConsume`'s consume sound before the burp, the `used` statistic, and the game event after the effects (so chorus fruit's eat event comes from where you land). - **`teleport_randomly` (chorus fruit)**: runs through horizon-world's verified `TeleportConsume` port (`tools/test_teleport_consume_parity.py`), which keeps vanilla's 16 attempts and its draws in order. For the player this PR adds `LivingEntity.randomTeleport` / `checkPositionAndTeleport`: - the world-border clamp and the loaded-chunk check; - the drop down to `entities_can_teleport_to` ground; - the player's box clear of blocks, entity boxes and liquid; - the `consumable_does_not_teleport_to` tag. On success: dismount (`stopRiding`), the `teleport` game event, the chorus sound, level event 2017's directional particles (also handled when a server sends them), entity event 46's portal particles, and the fall distance and impulse context reset. - `remote.rs`: the server-client eating animation from #787 reads the consumable's duration and particle flag instead of a fixed 32 ticks. ## Not in this PR - Chorus fruit's 1 s `use_cooldown`: Horizon has no item cooldowns yet (ender pearls don't have one either). - `Level.noCollision`'s world-border shape, in the teleport's collision check (the border clamp covers the centre). ## How tested | Check | Result | | --- | --- | | `cargo fmt --all` | ✅ | | `cargo clippy -p horizon-client --all-targets -- -D warnings` | ✅ | | `cargo test -p horizon-client` | ✅ every suite (844 + 66 + 22 tests) | | `tools/agent_control_e2e.py --scenario consume` (new: golden apple at full hunger, milk, honey, chorus fruit) | ✅ cli and mcp (teleported [4.66, 0, 7.65] and [-7.44, 0, 2.45]) | | `tools/parity.py --changed origin/main` (89 harnesses) | ✅ the harnesses covering the changed code: particle_providers, emitter_particles, entity_particles, first_person, use_item_on, sculk, hotbar, game_loop, sound_event (9/9), plus ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_particles, block_removal, block_transformer from the full `--changed` set before it was stopped. The full set (89 harnesses: every one with a horizon-client probe) would take hours on the busy Mac mini; CI runs the rest. | New unit tests: `items::tests::always_edible_and_consume_effects_loaded` (extended to cover milk, honey, dried kelp, chorus and chicken: timing, sound, animation, particles, remainders, effects) and `particles::tests::consume_teleport_unpacks_offsets_within_127`. On main, milk can't be drunk at all (`start_eating` required food), so the consume scenario fails there at its milk step. ## Needs Ludovic Nothing to decide here. 🤖 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:59:20 +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#2821
No description provided.