[PR #6371] [MERGED] Foxes take their food's consume effects and survive on a totem #6831

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

📋 Pull Request Information

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

Base: main ← Head: fix/fox-item-pickup


📝 Commits (2)

  • 5e07ad2 Foxes take their food's consume effects and survive on a totem
  • 6def659 Fox chorus test: skip without the vanilla data, as CI's unit tests run

📊 Changes

3 files changed (+321 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+6 -0)
📝 crates/horizon-client/src/mobs.rs (+118 -0)
📝 crates/horizon-client/src/mobs/fox.rs (+197 -3)

📄 Description

🤖 Opened by JustKarkat's AI agent.

Fixes #5839.

The pickup half is already on main. Foxes take dropped items since 0a1dd1fe1 ("Foxes and dolphins pick up items as vanilla", 2026-11-01), which is after the reported Nightly 2026-10-31 · d91cab6. This PR adds the two special item behaviours the report asks for on top of that.

  • Chorus fruit. Fox.aiStep finished food by only reading use_remainder, skipping ItemStack.finishUsingItem → Item.finishUsingItem → Consumable.onConsume and its on_consume_effects. The fox now runs them: TeleportRandomlyConsumeEffect draws 16 points in a cube of the item's diameter, clamps the height to [minY, minY + logicalHeight - 1], and takes the first where Entity.randomTeleport succeeds — first motion-blocking ground below, free box, no liquid, and not a #consumable_does_not_teleport_to block. Then entity.fox.teleport, the 2017 portal trail and resetFallDistance.
  • Totem of Undying. LivingEntity.checkTotemDeathProtection existed for players only, so a fox with a totem in its mouth died with it. Mob::damage now runs the vanilla rule for any mob: main hand first, then the off hand; the item is used up; health is set to 1; DeathProtection.TOTEM_EFFECTS (regeneration II 900, absorption II 100, fire resistance 800) are applied; entity event 35 goes out for the clients' totem particles and sound through the existing remote_totem path. A source in #bypasses_invulnerability (/kill, the void) still ignores it.

The death_protection lookup is by item id (minecraft:totem_of_undying), as game/totem.rs already does for the player: ItemInfo carries no components, so a mod item with the component would not be seen.

Checks

tools/pr_ready.py --quick, against origin/main at dea6dea98:

Check Result
Scope ✅ 3 files, +322 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 586 passed
rustfmt ✅
clippy ✅ (warnings denied)
tests: horizon-client ❌ 1203 passed, 1 failed
doc tests ✅
Parity ➖ 277 affected, to run in CI (--quick)

The one failure, entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation, also fails on unmodified origin/main on this machine (checked by stashing this branch's changes); it is unrelated to the change.

Parity harnesses run here: consumable, food, teleport_consume and entity_death_loot pass. mob_ai was stopped after 20+ minutes: its 1390 scenarios contain no fox case, so neither changed path is reachable from it.

Tests added: four totem_tests (main hand, off hand, no totem, bypassing blow) and one consume_tests chorus-fruit case that loads the real vanilla item data.


🔄 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/6371 **Author:** [@JustKarkat](https://github.com/JustKarkat) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/fox-item-pickup` --- ### 📝 Commits (2) - [`5e07ad2`](https://github.com/horizon-rust/horizon/commit/5e07ad2fc12b5aff18440f7c454a97f414629cc0) Foxes take their food's consume effects and survive on a totem - [`6def659`](https://github.com/horizon-rust/horizon/commit/6def6595b56eed58495e158ebf93fdd52805529c) Fox chorus test: skip without the vanilla data, as CI's unit tests run ### 📊 Changes **3 files changed** (+321 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+6 -0) 📝 `crates/horizon-client/src/mobs.rs` (+118 -0) 📝 `crates/horizon-client/src/mobs/fox.rs` (+197 -3) </details> ### 📄 Description > 🤖 Opened by JustKarkat's AI agent. Fixes #5839. **The pickup half is already on `main`.** Foxes take dropped items since `0a1dd1fe1` ("Foxes and dolphins pick up items as vanilla", 2026-11-01), which is after the reported `Nightly 2026-10-31 · d91cab6`. This PR adds the two special item behaviours the report asks for on top of that. * **Chorus fruit.** `Fox.aiStep` finished food by only reading `use_remainder`, skipping `ItemStack.finishUsingItem` → `Item.finishUsingItem` → `Consumable.onConsume` and its `on_consume_effects`. The fox now runs them: `TeleportRandomlyConsumeEffect` draws 16 points in a cube of the item's diameter, clamps the height to `[minY, minY + logicalHeight - 1]`, and takes the first where `Entity.randomTeleport` succeeds — first motion-blocking ground below, free box, no liquid, and not a `#consumable_does_not_teleport_to` block. Then `entity.fox.teleport`, the 2017 portal trail and `resetFallDistance`. * **Totem of Undying.** `LivingEntity.checkTotemDeathProtection` existed for players only, so a fox with a totem in its mouth died with it. `Mob::damage` now runs the vanilla rule for any mob: main hand first, then the off hand; the item is used up; health is set to 1; `DeathProtection.TOTEM_EFFECTS` (regeneration II 900, absorption II 100, fire resistance 800) are applied; entity event 35 goes out for the clients' totem particles and sound through the existing `remote_totem` path. A source in `#bypasses_invulnerability` (`/kill`, the void) still ignores it. The `death_protection` lookup is by item id (`minecraft:totem_of_undying`), as `game/totem.rs` already does for the player: `ItemInfo` carries no components, so a mod item with the component would not be seen. ## Checks `tools/pr_ready.py --quick`, against `origin/main` at `dea6dea98`: | Check | Result | | --- | --- | | Scope | ✅ 3 files, +322 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 586 passed | | rustfmt | ✅ | | clippy | ✅ (warnings denied) | | tests: horizon-client | ❌ 1203 passed, 1 failed | | doc tests | ✅ | | Parity | ➖ 277 affected, to run in CI (--quick) | The one failure, `entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation`, also fails on unmodified `origin/main` on this machine (checked by stashing this branch's changes); it is unrelated to the change. Parity harnesses run here: `consumable`, `food`, `teleport_consume` and `entity_death_loot` pass. `mob_ai` was stopped after 20+ minutes: its 1390 scenarios contain no fox case, so neither changed path is reachable from it. Tests added: four `totem_tests` (main hand, off hand, no totem, bypassing blow) and one `consume_tests` chorus-fruit case that loads the real vanilla item data. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:40 +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#6831
No description provided.