From 628388cf8fc8d16c7d2fc26c078f349880b3fed6 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 9 Jun 2024 21:39:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=B5=E5=87=BB=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../target/mobeffect/ShockMobEffect.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/mcreator/target/mobeffect/ShockMobEffect.java b/src/main/java/net/mcreator/target/mobeffect/ShockMobEffect.java index c04519528..9f1d09571 100644 --- a/src/main/java/net/mcreator/target/mobeffect/ShockMobEffect.java +++ b/src/main/java/net/mcreator/target/mobeffect/ShockMobEffect.java @@ -15,9 +15,9 @@ import net.minecraft.world.effect.MobEffectCategory; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.MobEffectEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -28,16 +28,7 @@ import net.minecraftforge.network.PacketDistributor; public class ShockMobEffect extends MobEffect { public ShockMobEffect() { super(MobEffectCategory.BENEFICIAL, -256); - addAttributeModifier(Attributes.MOVEMENT_SPEED, "7107DE5E-7CE8-4030-940E-514C1F160890", -2.0F, AttributeModifier.Operation.MULTIPLY_TOTAL); - } - - @Override - public void addAttributeModifiers(LivingEntity entity, AttributeMap attributeMap, int amplifier) { - if (!entity.level().isClientSide()) { - entity.level().playSound(null, BlockPos.containing(entity.getX(), entity.getY(), entity.getZ()), TargetModSounds.SHOCK.get(), SoundSource.HOSTILE, 1, 1); - } else { - entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), TargetModSounds.SHOCK.get(), SoundSource.HOSTILE, 1, 1, false); - } + addAttributeModifier(Attributes.MOVEMENT_SPEED, "7107DE5E-7CE8-4030-940E-514C1F160890", -10.0F, AttributeModifier.Operation.ADDITION); } @Override @@ -49,7 +40,8 @@ public class ShockMobEffect extends MobEffect { attacker = entity.level().getEntity(entity.getPersistentData().getInt("TargetShockAttacker")); } - entity.hurt(TargetModDamageTypes.causeShockDamage(entity.level().registryAccess(), attacker), 5.0f); + entity.hurt(TargetModDamageTypes.causeShockDamage(entity.level().registryAccess(), attacker), 2 * (amplifier + 1)); + entity.level().playSound(null, entity.getOnPos(), TargetModSounds.ELECTRIC.get(), SoundSource.PLAYERS, 1, 1); if (attacker instanceof ServerPlayer player) { player.level().playSound(null, player.blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); @@ -71,8 +63,16 @@ public class ShockMobEffect extends MobEffect { return; } + if (living instanceof Player) { + if (!living.level().isClientSide()) { + living.level().playSound(null, BlockPos.containing(living.getX(), living.getY(), living.getZ()), TargetModSounds.SHOCK.get(), SoundSource.HOSTILE, 1, 1); + } else { + living.level().playLocalSound(living.getX(), living.getY(), living.getZ(), TargetModSounds.SHOCK.get(), SoundSource.HOSTILE, 1, 1, false); + } + } + living.hurt(TargetModDamageTypes.causeShockDamage(living.level().registryAccess(), - event.getEffectSource()), 5.0f); + event.getEffectSource()), 2 * (instance.getAmplifier() + 1)); if (event.getEffectSource() instanceof LivingEntity source) { living.getPersistentData().putInt("TargetShockAttacker", source.getId());