Let a shulker bullet's levitation run out on mobs
This commit is contained in:
@@ -2385,7 +2385,7 @@ impl Game<'_> {
|
||||
if let Some(m) = self.mobs.iter_mut().find(|m| m.id == id)
|
||||
&& m.damage(4.0, source)
|
||||
{
|
||||
m.extra.levitation = 200;
|
||||
m.add_effect("minecraft:levitation", 200, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -677,7 +677,6 @@ pub struct Extra {
|
||||
pub anger: i32,
|
||||
pub carried: Option<horizon_world::registry::BlockStateId>,
|
||||
pub charged: bool,
|
||||
pub levitation: i32,
|
||||
/// Held item ids (main hand, off hand) and head item.
|
||||
pub main_hand: Option<Arc<str>>,
|
||||
pub off_hand: Option<Arc<str>>,
|
||||
|
||||
@@ -742,8 +742,14 @@ impl Mob {
|
||||
movement.y = 0.2;
|
||||
}
|
||||
let mut y = movement.y;
|
||||
if self.extra.levitation > 0 {
|
||||
y += (0.05 * 1.0 - movement.y) * 0.2;
|
||||
// LivingEntity.travelInAir: levitation lifts by its amplifier.
|
||||
if let Some(&(_, _, amp)) = self
|
||||
.extra
|
||||
.effects
|
||||
.iter()
|
||||
.find(|e| e.0 == "minecraft:levitation")
|
||||
{
|
||||
y += (0.05 * f64::from(amp + 1) - movement.y) * 0.2;
|
||||
} else {
|
||||
y -= self.gravity();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user