抽离呼吸回血数值

This commit is contained in:
Light_Quanta 2025-02-23 00:40:48 +08:00
parent 3d89adf341
commit fef8d94fe2
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 25 additions and 4 deletions

View file

@ -166,6 +166,11 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
this.entityData.set(KAMIKAZE_MODE, compound.getInt("KamikazeMode")); this.entityData.set(KAMIKAZE_MODE, compound.getInt("KamikazeMode"));
} }
@Override
public int maxRepairCoolDown() {
return -1;
}
@Override @Override
public void baseTick() { public void baseTick() {
pitchO = this.getBodyPitch(); pitchO = this.getBodyPitch();

View file

@ -66,7 +66,7 @@ public class VehicleEntity extends Entity {
public float roll; public float roll;
public float prevRoll; public float prevRoll;
public int lastHurtTick; public int lastHurtTick;
public int repairCoolDown; public int repairCoolDown = maxRepairCoolDown();
public boolean crash; public boolean crash;
public float getRoll() { public float getRoll() {
@ -162,7 +162,7 @@ public class VehicleEntity extends Entity {
} }
if (amount > 0) { if (amount > 0) {
lastHurtTick = 0; lastHurtTick = 0;
repairCoolDown = 200; repairCoolDown = maxRepairCoolDown();
} }
return super.hurt(source, amount); return super.hurt(source, amount);
@ -265,6 +265,20 @@ public class VehicleEntity extends Entity {
return 0; return 0;
} }
/**
* 呼吸回血冷却时长(单位:tick)设为小于0的值以禁用呼吸回血
*/
public int maxRepairCoolDown() {
return 200;
}
/**
* 呼吸回血回血量
*/
public float repairAmount() {
return 0.05F;
}
@Override @Override
public void baseTick() { public void baseTick() {
super.baseTick(); super.baseTick();
@ -308,10 +322,12 @@ public class VehicleEntity extends Entity {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
if (this.getHealth() <= 0.1 * this.getMaxHealth()) { if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
// 血量过低时自动扣血
this.hurt(0.1f, attacker, false); this.hurt(0.1f, attacker, false);
} else { } else {
if (!(this instanceof DroneEntity) && repairCoolDown == 0) { // 呼吸回血
this.heal(0.05f); if (repairCoolDown == 0) {
this.heal(repairAmount());
} }
} }