Merge pull request #2188 from kacpherek/fix/loot-set-stew-effect

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `SetStewEffectFunction` keeps the effect it rolled, with the duration times 20 unless the effect is instant. Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-26 19:10:53 +01:00
committed by GitHub
5 changed files with 30 additions and 1 deletions
@@ -23,6 +23,7 @@ fn stack(spec: &str) -> LootStack {
map: false,
exploration: None,
ominous_amplifier: None,
stew_effects: Vec::new(),
};
for e in parts {
let (name, level) = e.rsplit_once(':').unwrap_or((e, "1"));
@@ -3305,6 +3305,7 @@ fn to_loot(stack: &ItemStack) -> horizon_world::loot::LootStack {
map: false,
exploration: None,
ominous_amplifier: None,
stew_effects: Vec::new(),
}
}
/// A generated loot stack as a Horizon item stack.
+1
View File
@@ -304,6 +304,7 @@ fn loot_stack(item: &str, count: i32) -> LootStack {
map: false,
exploration: None,
ominous_amplifier: None,
stew_effects: Vec::new(),
}
}
/// `Mob.dropChances.byEquipment(slot)`: the recorded chance, or the one the
@@ -63,6 +63,12 @@ pub fn loot_item_with_components(s: &horizon_world::loot::LootStack) -> ItemStac
if let Some(level) = s.ominous_amplifier.filter(|l| *l > 0) {
item.data_mut().ominous_amplifier = Some(level.clamp(0, 4) as u8);
}
// set_stew_effect's `suspicious_stew_effects`.
for (effect, duration) in &s.stew_effects {
item.data_mut()
.stew_effects
.push((Arc::from(effect.as_str()), *duration));
}
item
}
@@ -248,6 +254,7 @@ mod tests {
map: false,
exploration: None,
ominous_amplifier: None,
stew_effects: Vec::new(),
};
// An End city chest's enchant_with_levels roll.
let boots = loot_item_with_components(&stack(
@@ -309,6 +316,7 @@ mod tests {
"zoom": 1
})))),
ominous_amplifier: None,
stew_effects: Vec::new(),
};
let mut item = loot_item(&stack);
assert!(has_pending_map(&item));
+19 -1
View File
@@ -31,6 +31,9 @@ pub struct LootStack {
pub exploration: Option<Box<ExplorationMap>>,
/// Set by set_ominous_bottle_amplifier.
pub ominous_amplifier: Option<i32>,
/// Added by set_stew_effect (the `suspicious_stew_effects` component):
/// (effect id, duration in ticks).
pub stew_effects: Vec<(String, i32)>,
}
/// `ExplorationMapFunction`'s settings.
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -74,6 +77,7 @@ impl LootStack {
map: false,
exploration: None,
ominous_amplifier: None,
stew_effects: Vec::new(),
}
}
pub fn is_empty(&self) -> bool {
@@ -678,6 +682,13 @@ impl LootData {
}
}
/// `MobEffect.isInstantaneous`.
fn is_instantaneous(effect: &str) -> bool {
matches!(
effect,
"minecraft:saturation" | "minecraft:instant_health" | "minecraft:instant_damage"
)
}
/// The level of one enchantment on a stack (its `enchantments` component).
fn item_level(stack: &LootStack, enchantment: &str) -> i32 {
stack
@@ -1134,7 +1145,14 @@ impl<R: RandomSource> Context<'_, R> {
.random
.next_int_bound(effects.len() as i32)
.unwrap_or(0) as usize;
self.int(&effects[pick]["duration"]);
let effect = effects[pick]["type"].as_str().unwrap_or("");
let mut duration = self.int(&effects[pick]["duration"]);
// Seconds, unless the effect is instantaneous.
if !is_instantaneous(effect) {
duration *= 20;
}
// SuspiciousStewEffects.withEffectAdded
stack.stew_effects.push((effect.to_owned(), duration));
}
}
"minecraft:set_ominous_bottle_amplifier" => {