Mobs standing in a wither rose get wither, bees in an open eyeblossom get poison

This commit is contained in:
Kacpherek
2026-10-26 19:55:27 +01:00
parent 72e678be8c
commit 7112d0cd64
+51
View File
@@ -413,6 +413,7 @@ pub fn tick(
super::axolotl::tick_animation(m);
m.anim.end_tick(m.ai.swinging);
tick_swing(m);
flower_contact_effects(m, w);
if m.species() == Species::CopperGolem {
// CopperGolem.tick: updateWeathering after the living tick.
super::copper_golem::update_weathering(m, w, level_random, events);
@@ -1464,6 +1465,56 @@ pub fn custom_travel(m: &mut Mob, w: &MobWorld, input: Vec3, events: &mut Vec<Mo
}
}
/// `Entity.applyEffectsFromBlocks` for the flowers that give an effect:
/// `WitherRoseBlock.entityInside` (wither for 40 ticks on a living mob that
/// can take it, not in peaceful) and `EyeblossomBlock.entityInside` (poison
/// for 25 ticks on a bee, when the open flower attracts bees). The blocks
/// are those the mob's box touches where it started the tick and where it
/// ended.
fn flower_contact_effects(m: &mut Mob, w: &MobWorld) {
if !m.alive() || w.difficulty.effective == 0.0 {
return;
}
let half = f64::from(m.width()) / 2.0 - 1.0e-5;
let height = f64::from(m.height()) - 1.0e-5;
let mut visited: Vec<[i32; 3]> = Vec::new();
for at in [m.previous, m.position] {
let cells = |lo: f64, hi: f64| lo.floor() as i32..=hi.floor() as i32;
for x in cells(at.x - half, at.x + half) {
for y in cells(at.y + 1.0e-5, at.y + height) {
for z in cells(at.z - half, at.z + half) {
let p = [x, y, z];
if visited.contains(&p) {
continue;
}
match w.block_name(x, y, z) {
"minecraft:wither_rose" => {
// isInvulnerableTo(wither): the invulnerable time
// after a hit; WitherBoss and WitherSkeleton
// refuse the effect (`canBeAffected`).
if m.invulnerable <= 0
&& !m.invulnerable_flag
&& !matches!(m.species(), Species::Wither | Species::WitherSkeleton)
{
m.add_effect("minecraft:wither", 40, 0);
}
}
"minecraft:open_eyeblossom"
if m.species() == Species::Bee
&& super::bee::attracts_bees(w, p)
&& !m.has_effect("minecraft:poison") =>
{
m.add_effect("minecraft:poison", 25, 0);
}
_ => continue,
}
visited.push(p);
}
}
}
}
}
/// MobEffect ticking for the effects mobs receive (poison, wither, regeneration).
fn tick_effects(m: &mut Mob) {
let mut effects = std::mem::take(&mut m.extra.effects);