修复药水效果的问题

This commit is contained in:
17146 2025-04-09 02:05:30 +08:00
parent 721fdf4bdd
commit 74e960b7b0
2 changed files with 4 additions and 7 deletions

View file

@ -20,7 +20,6 @@ import net.neoforged.neoforge.event.entity.living.MobEffectEvent;
import net.neoforged.neoforge.event.tick.EntityTickEvent; import net.neoforged.neoforge.event.tick.EntityTickEvent;
import net.neoforged.neoforge.network.PacketDistributor; import net.neoforged.neoforge.network.PacketDistributor;
// TODO 解决加上效果就立刻消失的问题
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME) @EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME)
public class BurnMobEffect extends MobEffect { public class BurnMobEffect extends MobEffect {
@ -44,8 +43,7 @@ public class BurnMobEffect extends MobEffect {
player.level().playSound(null, player.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); player.level().playSound(null, player.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5)); PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5));
} }
return true;
return false;
} }
@Override @Override

View file

@ -50,7 +50,7 @@ public class ShockMobEffect extends MobEffect {
player.level().playSound(null, player.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); player.level().playSound(null, player.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5)); PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5));
} }
return false; return true;
} }
@Override @Override
@ -58,13 +58,12 @@ public class ShockMobEffect extends MobEffect {
return duration % 20 == 0; return duration % 20 == 0;
} }
@SubscribeEvent @SubscribeEvent
public static void onEffectAdded(MobEffectEvent.Added event) { public static void onEffectAdded(MobEffectEvent.Added event) {
LivingEntity living = event.getEntity(); LivingEntity living = event.getEntity();
MobEffectInstance instance = event.getEffectInstance(); MobEffectInstance instance = event.getEffectInstance();
if (instance == null || !ModMobEffects.SHOCK.get().equals(instance.getEffect())) { if (instance == null || !ModMobEffects.SHOCK.get().equals(instance.getEffect().value())) {
return; return;
} }
@ -107,7 +106,7 @@ public class ShockMobEffect extends MobEffect {
return; return;
} }
if (instance.getEffect().equals(ModMobEffects.SHOCK.get())) { if (instance.getEffect().equals(ModMobEffects.SHOCK)) {
living.getPersistentData().remove("TargetShockAttacker"); living.getPersistentData().remove("TargetShockAttacker");
} }
} }