优化mobeffect
This commit is contained in:
parent
05cacbe570
commit
24e67ef912
2 changed files with 8 additions and 10 deletions
|
@ -1,10 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.mobeffect;
|
||||
|
||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModMobEffects;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
@ -23,6 +23,7 @@ import net.minecraftforge.network.PacketDistributor;
|
|||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class BurnMobEffect extends MobEffect {
|
||||
|
||||
public BurnMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, -12708330);
|
||||
}
|
||||
|
@ -36,7 +37,7 @@ public class BurnMobEffect extends MobEffect {
|
|||
attacker = entity.level().getEntity(entity.getPersistentData().getInt("BurnAttacker"));
|
||||
}
|
||||
|
||||
entity.hurt(new DamageSource(entity.level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(ModDamageTypes.BURN), attacker), 0.6f + (0.3f * amplifier));
|
||||
entity.hurt(ModDamageTypes.causeBurnDamage(entity.level().registryAccess(), attacker), 0.6f + (0.3f * amplifier));
|
||||
entity.invulnerableTime = 0;
|
||||
|
||||
if (attacker instanceof ServerPlayer player) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.mobeffect;
|
||||
|
||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModMobEffects;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
@ -28,6 +28,7 @@ import net.minecraftforge.network.PacketDistributor;
|
|||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class ShockMobEffect extends MobEffect {
|
||||
|
||||
public ShockMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, -256);
|
||||
addAttributeModifier(Attributes.MOVEMENT_SPEED, "7107DE5E-7CE8-4030-940E-514C1F160890", -10.0F, AttributeModifier.Operation.ADDITION);
|
||||
|
@ -124,16 +125,12 @@ public class ShockMobEffect extends MobEffect {
|
|||
if (event == null || event.getEntity() == null) {
|
||||
return;
|
||||
}
|
||||
shockCancelDamage(event);
|
||||
}
|
||||
|
||||
private static void shockCancelDamage(LivingAttackEvent event) {
|
||||
DamageSource source = event.getSource();
|
||||
Entity sourceentity = source.getDirectEntity();
|
||||
if (sourceentity == null) {
|
||||
Entity entity = source.getDirectEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
if (sourceentity instanceof LivingEntity living && living.hasEffect(ModMobEffects.SHOCK.get())) {
|
||||
if (entity instanceof LivingEntity living && living.hasEffect(ModMobEffects.SHOCK.get())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue