Merge pull request #2562 from levzzz5154/fix/potion-contents-in-the-creative-inventory
🤖 Agent: verified by Ludovic's AI agent (contrib gate 20): creative potions keep their contents (includes #2561). It passed in this wave's union with main on the Mac mini: the selected parity harnesses (332/332, then 122/122 on the final union), clippy -D warnings and the tests, and lan_e2e with the host on its server thread and in-frame (18/18 each). Thanks @levzzz5154!
This commit is contained in:
@@ -3238,4 +3238,37 @@ pub(crate) mod tests {
|
||||
assert_eq!(menu.quick_status, 0);
|
||||
});
|
||||
}
|
||||
|
||||
/// #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");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user