修复伤害可能为负的情况

This commit is contained in:
Atsuihsio 2024-11-08 19:19:04 +08:00
parent 3645f34051
commit 0e41fbfe83
2 changed files with 2 additions and 8 deletions

View file

@ -140,12 +140,9 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
amount *= 1.6f;
}
if (amount < 3) {
return false;
}
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * (amount - 5));
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * Math.max(amount - 5, 0));
return true;
}

View file

@ -146,12 +146,9 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
amount *= 1.6f;
}
if (amount < 3) {
return false;
}
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * (amount - 5));
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * Math.max(amount - 5, 0));
return true;
}