From 2adfd7519310fa69084f0e2988582b7630419b80 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Wed, 21 Oct 2026 12:09:17 +0200 Subject: [PATCH] Loot tables apply set_potion SetPotionFunction was skipped, so the potions a loot table gives came out with no contents: a piglin's barter never held fire resistance (the drinkable and splash ones, 16 of 469), only uncraftable potions. The merchant and /loot code had it; the shared loot evaluator now does too. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 1b2767122d7ffc9faf8d8359f49e86bab5054979) --- crates/horizon-client/src/items.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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"))