steel_core/entity/mob_effect/
poison.rs1use steel_registry::vanilla_damage_types;
4
5use super::MobEffectBehavior;
6use crate::entity::LivingEntity;
7use crate::entity::damage::DamageSource;
8use crate::world::World;
9
10const DAMAGE_INTERVAL: i32 = 25;
11
12pub struct PoisonBehavior;
15
16impl MobEffectBehavior for PoisonBehavior {
17 fn should_apply_effect_tick_this_tick(&self, tick_count: i32, amplifier: i32) -> bool {
18 let interval = DAMAGE_INTERVAL.wrapping_shr(amplifier as u32);
19 interval <= 0 || tick_count % interval == 0
20 }
21
22 fn apply_effect_tick(&self, world: &World, user: &dyn LivingEntity, _amplifier: i32) -> bool {
23 if user.get_health() > 1.0 {
24 user.hurt(
25 world,
26 &DamageSource::environment(&vanilla_damage_types::MAGIC),
27 1.0,
28 );
29 }
30 true
31 }
32}