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 <noreply@anthropic.com> (cherry picked from commit 1b2767122d7ffc9faf8d8359f49e86bab5054979)
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user