[PR #4506] [MERGED] Make an allay tell potions apart #5664

Closed
opened 2026-11-03 05:14:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4506
Author: @MSedgeMC
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/allay-potion-match


📝 Commits (2)

  • 1d4c9fa Make an allay tell potions apart
  • e3a24be Merge remote-tracking branch 'origin/main' into fix-4506

📊 Changes

3 files changed (+84 additions, -19 deletions)

View changed files

📝 crates/horizon-client/src/game/allays.rs (+34 -18)
📝 crates/horizon-client/src/game/creatures.rs (+1 -1)
📝 crates/horizon-client/src/mobs/allay.rs (+49 -0)

📄 Description

Fixes the AllayAi.hasNonMatchingPotion row in the port ledger. (No issue. The sibling hearNoteblock row was stale — that landed as #3946 — so it is left alone.)

AllayAi.allayConsidersItemEqual(a, b) is ItemStack.isSameItem(a, b) && !hasNonMatchingPotion(a, b), and hasNonMatchingPotion compares the potion_contents component. An allay holding a potion of Swiftness therefore ignores a potion of Healing lying next to it. Horizon compared item ids only (e.stack.item == held), so any allay fetched every potion, and it kept only the item id of what it carried, so delivery and hand-back dropped the components too.

The rule is now a small helper in mobs/allay.rs — same item and same potion id, an absent component counting as empty so two plain stacks still match — and the allay carries the whole stack: the fetch check uses the helper, pickup stores the fetched stack on the mob, and delivery, the throw and the hand-back all use that stack instead of rebuilding it from an id. That also means a potion-carrying allay keeps its potion across save and load, since the hand stack is written with its components.

What is proven: cargo test -p horizon-client --lib allay::allay_parity_tests → 2 passed on a build box: Swiftness vs Healing are not equal, two Swiftness are, plain stacks match by item, and a plain minecraft:potion with no contents does not match a brewed one.

What is not proven: the game-level behaviour — an allay given a Swiftness potion ignoring Healing potions dropped nearby — has no harness or fixture (there is no allay harness and tick_allays is a method on the bin-only Game), so nobody has watched it. pr_ready was not run, so CI's verify is the workspace check.

One known approximation, marked with a shortcut: comment: only the potion id is compared. Vanilla compares the whole PotionContents record (custom effects, colour, name), and StackData keeps only the id — two potions with the same id but different custom effects would compare equal here.


🔄 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/4506 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/allay-potion-match` --- ### 📝 Commits (2) - [`1d4c9fa`](https://github.com/horizon-rust/horizon/commit/1d4c9fa4db3d1f995ebca3b83b7d4ec4b659c225) Make an allay tell potions apart - [`e3a24be`](https://github.com/horizon-rust/horizon/commit/e3a24beec6f3adc929973f2d42f00a4be5dea830) Merge remote-tracking branch 'origin/main' into fix-4506 ### 📊 Changes **3 files changed** (+84 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/allays.rs` (+34 -18) 📝 `crates/horizon-client/src/game/creatures.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/allay.rs` (+49 -0) </details> ### 📄 Description Fixes the `AllayAi.hasNonMatchingPotion` row in the port ledger. (No issue. The sibling `hearNoteblock` row was stale — that landed as #3946 — so it is left alone.) `AllayAi.allayConsidersItemEqual(a, b)` is `ItemStack.isSameItem(a, b) && !hasNonMatchingPotion(a, b)`, and `hasNonMatchingPotion` compares the `potion_contents` component. An allay holding a potion of Swiftness therefore ignores a potion of Healing lying next to it. Horizon compared item ids only (`e.stack.item == held`), so any allay fetched every potion, and it kept only the item **id** of what it carried, so delivery and hand-back dropped the components too. The rule is now a small helper in `mobs/allay.rs` — same item and same potion id, an absent component counting as empty so two plain stacks still match — and the allay carries the whole stack: the fetch check uses the helper, pickup stores the fetched stack on the mob, and delivery, the throw and the hand-back all use that stack instead of rebuilding it from an id. That also means a potion-carrying allay keeps its potion across save and load, since the hand stack is written with its components. **What is proven:** `cargo test -p horizon-client --lib allay::allay_parity_tests` → 2 passed on a build box: Swiftness vs Healing are not equal, two Swiftness are, plain stacks match by item, and a plain `minecraft:potion` with no contents does not match a brewed one. **What is not proven:** the game-level behaviour — an allay given a Swiftness potion ignoring Healing potions dropped nearby — has no harness or fixture (there is no allay harness and `tick_allays` is a method on the bin-only `Game`), so nobody has watched it. `pr_ready` was not run, so CI's `verify` is the workspace check. One known approximation, marked with a `shortcut:` comment: only the potion id is compared. Vanilla compares the whole `PotionContents` record (custom effects, colour, name), and `StackData` keeps only the id — two potions with the same id but different custom effects would compare equal here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:10 +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#5664
No description provided.