From 7ae20a5b294ebc8891ae8faabc42496c187356d3 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 27 Oct 2026 04:07:36 +0500 Subject: [PATCH] A potion from the creative inventory keeps its contents in the hotbar #1832 reported that a potion taken from the creative inventory and put in the hotbar turned into the uncraftable potion. The hand-over keeps the stack as it is on `main` (#1796 and #1874), so this adds the test that keeps it that way: the item tab's stack is the real one, the creative screen hands it over unchanged, and the hotbar slot holds the brew. Fixes #1832 Co-Authored-By: minimax-m3.1-flash (Claude Code) --- crates/horizon-client/src/menu.rs | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/horizon-client/src/menu.rs b/crates/horizon-client/src/menu.rs index 3b2b8fd31..38186d170 100644 --- a/crates/horizon-client/src/menu.rs +++ b/crates/horizon-client/src/menu.rs @@ -3211,4 +3211,37 @@ pub(crate) mod tests { assert_eq!(menu.slot(0), stack("dirt", 1).as_ref()); }); } + + /// #1832: a potion taken from the creative inventory and put in the + /// hotbar keeps its `PotionContents` (the brew), as vanilla's + /// `PotionContents.createItemStack` builds it: the item tab's stack is + /// the real one, and the hotbar slot holds it as it is. + #[test] + fn a_creative_potion_keeps_its_contents_in_the_hotbar() { + let snbt = r#"{components:{"minecraft:potion_contents":{potion:"minecraft:swiftness"}},count:1,id:"minecraft:potion"}"#; + let potion = crate::item_data::parse_stack(snbt).unwrap().unwrap(); + assert_eq!(potion.potion(), Some("minecraft:swiftness")); + // The creative screen hands the stack over... + let mut carried = None; + crate::creative::click_display( + &mut carried, + Some(&potion), + |_: &ItemStack| 1, + 0, + Input::Pickup, + ); + assert_eq!( + carried.as_ref().and_then(|s| s.potion()), + Some("minecraft:swiftness") + ); + // ... and the hotbar slot keeps it: it is not the uncraftable + // potion, which is a `minecraft:potion` with no contents at all. + with_menu(Kind::ItemPicker, |env, menu| { + menu.carried = carried; + menu.click(env, 45, 0, Input::Pickup).unwrap(); + let in_hand = menu.slot(45).expect("the hotbar slot"); + assert_eq!(in_hand.potion(), Some("minecraft:swiftness")); + assert_eq!(&*in_hand.item, "minecraft:potion"); + }); + } }