添加电击效果初次伤害逻辑
This commit is contained in:
parent
bbdc7d30b5
commit
0458f1a61b
1 changed files with 9 additions and 14 deletions
|
@ -54,22 +54,17 @@ public class ShockMobEffect extends MobEffect {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onEffectAdded(MobEffectEvent.Added event) {
|
public static void onEffectAdded(MobEffectEvent.Added event) {
|
||||||
LivingEntity living = event.getEntity();
|
LivingEntity living = event.getEntity();
|
||||||
if (event.getEffectSource() instanceof LivingEntity source) {
|
|
||||||
MobEffectInstance instance = event.getEffectInstance();
|
|
||||||
|
|
||||||
|
MobEffectInstance instance = event.getEffectInstance();
|
||||||
if (!instance.getEffect().equals(TargetModMobEffects.SHOCK.get())) {
|
if (!instance.getEffect().equals(TargetModMobEffects.SHOCK.get())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
living.getPersistentData().putInt("TargetShockAttacker", source.getId());
|
|
||||||
|
|
||||||
if (living.hasEffect(TargetModMobEffects.SHOCK.get())) {
|
|
||||||
System.out.println(instance.getDuration());
|
|
||||||
if (instance.getDuration() % 10 == 0) {
|
|
||||||
living.hurt(TargetModDamageTypes.causeShockDamage(living.level().registryAccess(),
|
living.hurt(TargetModDamageTypes.causeShockDamage(living.level().registryAccess(),
|
||||||
source), 5.0f);
|
event.getEffectSource()), 5.0f);
|
||||||
}
|
|
||||||
}
|
if (event.getEffectSource() instanceof LivingEntity source) {
|
||||||
|
living.getPersistentData().putInt("TargetShockAttacker", source.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue