优化子弹伤害判定
This commit is contained in:
parent
c0e95ed8fb
commit
97e6012266
1 changed files with 7 additions and 9 deletions
|
@ -714,23 +714,21 @@ public class ProjectileEntity extends Projectile implements IEntityAdditionalSpa
|
||||||
this.xRotO = this.getXRot();
|
this.xRotO = this.getXRot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performDamage(Entity entity, float damage, boolean headshot) {
|
private void performDamage(Entity entity, float damage, boolean isHeadshot) {
|
||||||
float rate = Mth.clamp(this.bypassArmorRate, 0, 1);
|
float rate = Mth.clamp(this.bypassArmorRate, 0, 1);
|
||||||
|
|
||||||
float normalDamage = damage * Mth.clamp(1 - rate, 0, 1);
|
float normalDamage = damage * Mth.clamp(1 - rate, 0, 1);
|
||||||
float absoluteDamage = damage * Mth.clamp(rate, 0, 1);
|
float absoluteDamage = damage * Mth.clamp(rate, 0, 1);
|
||||||
|
|
||||||
entity.invulnerableTime = 0;
|
entity.invulnerableTime = 0;
|
||||||
if (headshot) {
|
|
||||||
entity.hurt(ModDamageTypes.causeGunFireHeadshotDamage(this.level().registryAccess(), this, this.shooter), normalDamage * this.headShot);
|
|
||||||
entity.invulnerableTime = 0;
|
|
||||||
entity.hurt(ModDamageTypes.causeGunFireHeadshotAbsoluteDamage(this.level().registryAccess(), this, this.shooter), absoluteDamage * this.headShot);
|
|
||||||
entity.invulnerableTime = 0;
|
|
||||||
|
|
||||||
} else {
|
float headShotModifier = isHeadshot ? this.headShot : 1;
|
||||||
entity.hurt(ModDamageTypes.causeGunFireDamage(this.level().registryAccess(), this, this.shooter), normalDamage);
|
if (normalDamage > 0) {
|
||||||
|
entity.hurt(ModDamageTypes.causeGunFireHeadshotDamage(this.level().registryAccess(), this, this.shooter), normalDamage * headShotModifier);
|
||||||
entity.invulnerableTime = 0;
|
entity.invulnerableTime = 0;
|
||||||
entity.hurt(ModDamageTypes.causeGunFireAbsoluteDamage(this.level().registryAccess(), this, this.shooter), absoluteDamage);
|
}
|
||||||
|
if (absoluteDamage > 0) {
|
||||||
|
entity.hurt(ModDamageTypes.causeGunFireHeadshotAbsoluteDamage(this.level().registryAccess(), this, this.shooter), absoluteDamage * headShotModifier);
|
||||||
entity.invulnerableTime = 0;
|
entity.invulnerableTime = 0;
|
||||||
|
|
||||||
//大于1的穿甲对载具造成额外伤害
|
//大于1的穿甲对载具造成额外伤害
|
||||||
|
|
Loading…
Add table
Reference in a new issue