steel_core/entity/mob_effect/
regeneration.rs1use super::MobEffectBehavior;
4use crate::entity::LivingEntity;
5use crate::world::World;
6
7const HEAL_INTERVAL: i32 = 50;
8
9pub struct RegenerationBehavior;
11
12impl MobEffectBehavior for RegenerationBehavior {
13 fn should_apply_effect_tick_this_tick(&self, tick_count: i32, amplifier: i32) -> bool {
14 let interval = HEAL_INTERVAL.wrapping_shr(amplifier as u32);
15 interval <= 0 || tick_count % interval == 0
16 }
17
18 fn apply_effect_tick(&self, _world: &World, user: &dyn LivingEntity, _amplifier: i32) -> bool {
19 if user.get_health() < user.get_max_health() {
20 user.heal(1.0);
21 }
22 true
23 }
24}