修复载具在客户端被攻击的虚假扣血,修复直升机功率条同步问题
This commit is contained in:
parent
4247ca342a
commit
c395abd0df
3 changed files with 21 additions and 14 deletions
|
@ -79,7 +79,7 @@ public class HelicopterHudOverlay {
|
||||||
|
|
||||||
float power = iHelicopterEntity.getPower();
|
float power = iHelicopterEntity.getPower();
|
||||||
lerpPower = Mth.lerp(0.001f * event.getPartialTick(), lerpPower, power);
|
lerpPower = Mth.lerp(0.001f * event.getPartialTick(), lerpPower, power);
|
||||||
preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/helicopter/heli_power.png"), (float) w / 2 + 130f, ((float) h / 2 - 64 + 124 - power * 900), 0, 0, 4, power * 900, 4, power * 900);
|
preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/helicopter/heli_power.png"), (float) w / 2 + 130f, ((float) h / 2 - 64 + 124 - power * 970), 0, 0, 4, power * 970, 4, power * 970);
|
||||||
lerpVy = (float) Mth.lerp(0.021f * event.getPartialTick(), lerpVy, mobileVehicle.getDeltaMovement().y() + 0.06f);
|
lerpVy = (float) Mth.lerp(0.021f * event.getPartialTick(), lerpVy, mobileVehicle.getDeltaMovement().y() + 0.06f);
|
||||||
preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/helicopter/heli_vy_move.png"), (float) w / 2 + 100, ((float) h / 2 - 64 - Math.max(lerpVy, 0) * 100f), 0, 0, 64, 128, 64, 128);
|
preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/helicopter/heli_vy_move.png"), (float) w / 2 + 100, ((float) h / 2 - 64 - Math.max(lerpVy, 0) * 100f), 0, 0, 64, 128, 64, 128);
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(mobileVehicle.getY())),
|
event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(mobileVehicle.getY())),
|
||||||
|
|
|
@ -131,21 +131,23 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
||||||
this.setXRot(Mth.clamp(this.getXRot() + (this.onGround() ? 0 : 1.2f) * diffX * this.entityData.get(POWER), -80, 80));
|
this.setXRot(Mth.clamp(this.getXRot() + (this.onGround() ? 0 : 1.2f) * diffX * this.entityData.get(POWER), -80, 80));
|
||||||
this.setZRot(Mth.clamp(this.getRoll() - this.entityData.get(DELTA_ROT) + (this.onGround() ? 0 : 0.75f) * diffY * this.entityData.get(POWER), -50, 50));
|
this.setZRot(Mth.clamp(this.getRoll() - this.entityData.get(DELTA_ROT) + (this.onGround() ? 0 : 0.75f) * diffY * this.entityData.get(POWER), -50, 50));
|
||||||
|
|
||||||
if (this.upInputDown || this.forwardInputDown) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 0.12f));
|
if (this.upInputDown || this.forwardInputDown) {
|
||||||
}
|
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 0.12f));
|
||||||
|
}
|
||||||
|
|
||||||
if (this.downInputDown || this.backInputDown) {
|
if (this.downInputDown || this.backInputDown) {
|
||||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0015f, 0));
|
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0015f, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(this.getDeltaMovement().y())), true);
|
// player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(this.getDeltaMovement().y())), true);
|
||||||
|
|
||||||
if(!(this.upInputDown || this.forwardInputDown || this.downInputDown || this.backInputDown)) {
|
if(!(this.upInputDown || this.forwardInputDown || this.downInputDown || this.backInputDown)) {
|
||||||
if (this.getDeltaMovement().y() + 0.06 < 0) {
|
if (this.getDeltaMovement().y() + 0.06 < 0) {
|
||||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0002f, 0.12f));
|
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0002f, 0.12f));
|
||||||
} else {
|
} else {
|
||||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0006f, 0));
|
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0006f, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,11 +161,16 @@ public class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void heal(float pHealAmount) {
|
public void heal(float pHealAmount) {
|
||||||
this.setHealth(this.getHealth() + pHealAmount);
|
if (this.level() instanceof ServerLevel) {
|
||||||
|
this.setHealth(this.getHealth() + pHealAmount);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hurt(float pHealAmount) {
|
public void hurt(float pHealAmount) {
|
||||||
this.setHealth(this.getHealth() - pHealAmount);
|
if (this.level() instanceof ServerLevel) {
|
||||||
|
this.setHealth(this.getHealth() - pHealAmount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHealth() {
|
public float getHealth() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue