diff --git a/crates/horizon-client/src/items.rs b/crates/horizon-client/src/items.rs index edf094d39..ab9c98804 100644 --- a/crates/horizon-client/src/items.rs +++ b/crates/horizon-client/src/items.rs @@ -1434,6 +1434,13 @@ impl LootContext<'_> { .count() as u32; } } + // SetPotionFunction (the barter's fire resistance potions). + "minecraft:set_potion" => { + if let Some(id) = f["id"].as_str() { + *stack = std::mem::replace(stack, ItemStack::new("minecraft:air", 0)) + .with_potion(id); + } + } "minecraft:limit_count" => { let limit = &f["limit"]; if let Some(min) = limit["min"].as_i64() { @@ -1631,6 +1638,18 @@ mod tests { ); } + #[test] + fn set_potion_gives_the_potion_its_contents() { + let items = Items::for_tests(HashMap::new()); + let props = BTreeMap::new(); + let table = json!({"pools":[{"rolls":1,"entries":[{"type":"minecraft:item","name":"minecraft:splash_potion", + "modifier":{"type":"minecraft:set_potion","id":"minecraft:fire_resistance"}}]}]}); + let drops = ctx(&items, None, &props, "").evaluate(&table, &mut LegacyRandom::new(1)); + assert_eq!(drops.len(), 1); + assert_eq!(&*drops[0].item, "minecraft:splash_potion"); + assert_eq!(drops[0].potion(), Some("minecraft:fire_resistance")); + } + #[test] fn always_edible_and_consume_effects_loaded() { let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))