修复伤害可能为负的情况
This commit is contained in:
parent
3645f34051
commit
0e41fbfe83
2 changed files with 2 additions and 8 deletions
|
@ -140,12 +140,9 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
|
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
|
||||||
amount *= 1.6f;
|
amount *= 1.6f;
|
||||||
}
|
}
|
||||||
if (amount < 3) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,9 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
|
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
|
||||||
amount *= 1.6f;
|
amount *= 1.6f;
|
||||||
}
|
}
|
||||||
if (amount < 3) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue