From 1415430079651a3092a633d7451282ff65dc1b07 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Wed, 2 Apr 2025 16:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4mob=20effect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobeffect/BurnMobEffect.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/mobeffect/BurnMobEffect.java b/src/main/java/com/atsuishio/superbwarfare/mobeffect/BurnMobEffect.java index e90fd6995..73cc587a3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mobeffect/BurnMobEffect.java +++ b/src/main/java/com/atsuishio/superbwarfare/mobeffect/BurnMobEffect.java @@ -17,8 +17,10 @@ import net.minecraft.world.entity.LivingEntity; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.entity.living.MobEffectEvent; +import net.neoforged.neoforge.event.tick.EntityTickEvent; import net.neoforged.neoforge.network.PacketDistributor; +// TODO 解决加上效果就立刻消失的问题 @EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME) public class BurnMobEffect extends MobEffect { @@ -99,18 +101,17 @@ public class BurnMobEffect extends MobEffect { } } - // TODO tick event? -// @SubscribeEvent -// public static void onLivingTick(EntityTickEvent event) { -// var entity = event.getEntity(); -// if (!(entity instanceof LivingEntity living)) return; -// -// if (living.hasEffect(ModMobEffects.BURN)) { -// living.setRemainingFireTicks(2); -// } -// -// if (living.isInWater()) { -// living.removeEffect(ModMobEffects.BURN); -// } -// } + @SubscribeEvent + public static void onLivingTick(EntityTickEvent.Post event) { + var entity = event.getEntity(); + if (!(entity instanceof LivingEntity living)) return; + + if (living.hasEffect(ModMobEffects.BURN)) { + living.setRemainingFireTicks(2); + } + + if (living.isInWater()) { + living.removeEffect(ModMobEffects.BURN); + } + } }