潜行键手动放下/收起起落架

This commit is contained in:
Atsuishio 2025-05-18 19:07:54 +08:00 committed by Light_Quanta
parent 98ecf88a45
commit 6812e71aae
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 23 additions and 25 deletions

View file

@ -70,8 +70,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.STRING);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private boolean fly;
private int flyTime;
private boolean gearUp;
public int fireIndex;
public int reloadCoolDownBomb;
public int reloadCoolDownMissile;
@ -525,8 +524,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.entityData.set(POWER, this.entityData.get(POWER) * 0.8f);
this.setDeltaMovement(this.getDeltaMovement().multiply(0.97, 1, 0.97));
} else {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.95f);
this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 1, 0.99));
this.entityData.set(POWER, this.entityData.get(POWER) * 0.97f);
this.setDeltaMovement(this.getDeltaMovement().multiply(0.994, 1, 0.994));
}
this.entityData.set(PLANE_BREAK, Math.min(this.entityData.get(PLANE_BREAK) + 10, 60f));
}
@ -560,23 +559,20 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER));
// 起落架
if (!SeekTool.isOnGround(this, 15)) {
flyTime = Math.min(flyTime + 1, 10);
if (downInputDown) {
downInputDown = false;
if (entityData.get(GEAR_ROT) == 0 && !onGround()) {
entityData.set(GEAR_UP, true);
} else if (entityData.get(GEAR_ROT) == 85) {
entityData.set(GEAR_UP, false);
}
}
if (SeekTool.isOnGround(this, 15) && fly) {
flyTime = Math.max(flyTime - 1, 0);
if (onGround()) {
entityData.set(GEAR_UP, false);
}
if (!fly && flyTime == 10) {
fly = true;
}
if (fly && flyTime == 0) {
fly = false;
}
if (fly) {
if (entityData.get(GEAR_UP)) {
entityData.set(GEAR_ROT, Math.min(entityData.get(GEAR_ROT) + 5, 85));
} else {
entityData.set(GEAR_ROT, Math.max(entityData.get(GEAR_ROT) - 5, 0));
@ -584,13 +580,13 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
float flapX = (1 - (Mth.abs(getRoll())) / 90) * Mth.clamp(diffX, -22.5f, 22.5f) - VectorTool.calculateY(getRoll()) * Mth.clamp(diffY, -22.5f, 22.5f);
setFlap1LRot(Mth.clamp(-flapX - 8 * addZ - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1RRot(Mth.clamp(-flapX + 8 * addZ - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1L2Rot(Mth.clamp(-flapX - 8 * addZ + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1R2Rot(Mth.clamp(-flapX + 8 * addZ + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1LRot(Mth.clamp(-flapX - 4 * addZ - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1RRot(Mth.clamp(-flapX + 4 * addZ - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1L2Rot(Mth.clamp(-flapX - 4 * addZ + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1R2Rot(Mth.clamp(-flapX + 4 * addZ + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap2LRot(Mth.clamp(flapX - 8 * addZ, -22.5f, 22.5f));
setFlap2RRot(Mth.clamp(flapX + 8 * addZ, -22.5f, 22.5f));
setFlap2LRot(Mth.clamp(flapX - 4 * addZ, -22.5f, 22.5f));
setFlap2RRot(Mth.clamp(flapX + 4 * addZ, -22.5f, 22.5f));
float flapY = (1 - (Mth.abs(getRoll())) / 90) * Mth.clamp(diffY, -22.5f, 22.5f) + VectorTool.calculateY(getRoll()) * Mth.clamp(diffX, -22.5f, 22.5f);

View file

@ -64,6 +64,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> DECOY_COUNT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> GEAR_ROT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Boolean> GEAR_UP = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Float> PLANE_BREAK = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.FLOAT);
private Vec3 previousVelocity = Vec3.ZERO;
@ -866,6 +867,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
.define(COAX_HEAT, 0)
.define(DECOY_COUNT, 0)
.define(GEAR_ROT, 0)
.define(GEAR_UP, false)
.define(PLANE_BREAK, 0f);
}
@ -875,6 +877,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
this.entityData.set(POWER, compound.getFloat("Power"));
this.entityData.set(DECOY_COUNT, compound.getInt("DecoyCount"));
this.entityData.set(GEAR_ROT, compound.getInt("GearRot"));
this.entityData.set(GEAR_UP, compound.getBoolean("GearUp"));
}
@Override
@ -883,6 +886,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
compound.putFloat("Power", this.entityData.get(POWER));
compound.putInt("DecoyCount", this.entityData.get(DECOY_COUNT));
compound.putInt("GearRot", this.entityData.get(GEAR_ROT));
compound.putBoolean("GearUp", this.entityData.get(GEAR_UP));
}
public boolean canCrushEntities() {

View file

@ -221,8 +221,6 @@ public class SeekTool {
onGround.set(true);
}
});
return entity.onGround() || entity.isInWater() || onGround.get();
}