steel_core/entity/mob_effect/
hunger.rs1use super::MobEffectBehavior;
4use crate::entity::LivingEntity;
5use crate::world::World;
6
7pub struct HungerBehavior;
9
10const EXHAUSTION_PER_LEVEL: f32 = 0.005;
12
13impl MobEffectBehavior for HungerBehavior {
14 fn should_apply_effect_tick_this_tick(&self, _tick_count: i32, _amplifier: i32) -> bool {
15 true
16 }
17
18 fn apply_effect_tick(&self, _world: &World, user: &dyn LivingEntity, amplifier: i32) -> bool {
19 if let Some(player) = user.as_player() {
20 player.cause_food_exhaustion(EXHAUSTION_PER_LEVEL * (amplifier + 1) as f32);
21 }
22 true
23 }
24}