添加A10减速板

This commit is contained in:
Atsuishio 2025-05-13 21:46:52 +08:00 committed by Light_Quanta
parent c21662b1c0
commit 0a5d917c41
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 126 additions and 67 deletions

View file

@ -55,10 +55,16 @@ public class A10Renderer extends GeoEntityRenderer<A10Entity> {
public void renderRecursively(PoseStack poseStack, A10Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
String name = bone.getName();
if (name.equals("wingLR")) {
bone.setRotX(Mth.lerp(partialTick, animatable.flap1LRotO, animatable.getFlap1LRot()) * Mth.DEG_TO_RAD);
bone.setRotX(1.5f * Mth.lerp(partialTick, animatable.flap1LRotO, animatable.getFlap1LRot()) * Mth.DEG_TO_RAD);
}
if (name.equals("wingRR")) {
bone.setRotX(Mth.lerp(partialTick, animatable.flap1RRotO, animatable.getFlap1RRot()) * Mth.DEG_TO_RAD);
bone.setRotX(1.5f * Mth.lerp(partialTick, animatable.flap1RRotO, animatable.getFlap1RRot()) * Mth.DEG_TO_RAD);
}
if (name.equals("wingLR2")) {
bone.setRotX(1.5f * Mth.lerp(partialTick, animatable.flap1L2RotO, animatable.getFlap1L2Rot()) * Mth.DEG_TO_RAD);
}
if (name.equals("wingRR2")) {
bone.setRotX(1.5f * Mth.lerp(partialTick, animatable.flap1R2RotO, animatable.getFlap1R2Rot()) * Mth.DEG_TO_RAD);
}
if (name.equals("wingLB")) {
bone.setRotX(Mth.lerp(partialTick, animatable.flap2LRotO, animatable.getFlap2LRot()) * Mth.DEG_TO_RAD);

View file

@ -321,10 +321,10 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
}
}
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.35 * this.getBbWidth(), 0.12 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.05, true);
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.1 * this.getBbWidth(), 0.05 * this.getBbHeight(), 0.1 * this.getBbWidth(), 0.4, true);
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.35 * this.getBbWidth(), 0.12 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.05, true);
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.1 * this.getBbWidth(), 0.05 * this.getBbHeight(), 0.1 * this.getBbWidth(), 0.4, true);
}
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
@ -497,8 +497,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
@Override
public void travel() {
Entity passenger = this.getFirstPassenger();
float diffX;
float diffY;
float diffX = 0;
float diffY = 0;
if (getHealth() > 0.1f * getMaxHealth()) {
@ -530,16 +530,40 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
} else if (this.leftInputDown) {
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.4f);
}
} else {
}
// 刹车
if (upInputDown) {
if (onGround()) {
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(PLANE_BREAK, Math.min(this.entityData.get(PLANE_BREAK) + 10, 60f));
}
diffY = Mth.clamp(Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()), -90f, 90f);
diffX = Mth.clamp(Mth.wrapDegrees(passenger.getXRot() - this.getXRot()), -90f, 90f);
}
} else if (!onGround()) {
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0003f, 0.02f));
destroyRot += 0.1f;
diffX = 90 - this.getXRot();
this.setXRot(this.getXRot() + diffX * 0.0015f * destroyRot);
this.setZRot(this.getRoll() - destroyRot);
setDeltaMovement(getDeltaMovement().add(0, -0.03, 0));
setDeltaMovement(getDeltaMovement().add(0, -destroyRot * 0.005, 0));
}
this.entityData.set(POWER, this.entityData.get(POWER) * 0.99f);
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f);
this.entityData.set(PLANE_BREAK, this.entityData.get(PLANE_BREAK) * 0.8f);
if (getEnergy() > 0 && !this.level().isClientSide) {
this.consumeEnergy((int) (Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get()));
}
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
@ -556,14 +580,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.setZRot(this.getRoll() - addZ * (1 - Mth.abs(i)));
}
setFlap1LRot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) - 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap1RRot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) + 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap2LRot(Mth.clamp(Mth.clamp(diffX, -22.5f, 22.5f) - 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap2RRot(Mth.clamp(Mth.clamp(diffX, -22.5f, 22.5f) + 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap3Rot(diffY * 0.7f);
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER));
// 起落架
@ -588,26 +604,19 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
} else {
entityData.set(GEAR_ROT, Math.max(entityData.get(GEAR_ROT) - 5, 0));
}
}
} else if (!onGround()) {
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0003f, 0.02f));
destroyRot += 0.1f;
diffX = 90 - this.getXRot();
this.setXRot(this.getXRot() + diffX * 0.0015f * destroyRot);
this.setZRot(this.getRoll() - destroyRot);
setDeltaMovement(getDeltaMovement().add(0, -0.03, 0));
setDeltaMovement(getDeltaMovement().add(0, -destroyRot * 0.005, 0));
}
this.entityData.set(POWER, this.entityData.get(POWER) * 0.99f);
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f);
setFlap1LRot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) - 8 * addZ * (1 - Mth.abs(i)) - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1RRot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) + 8 * addZ * (1 - Mth.abs(i)) - this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1L2Rot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) - 8 * addZ * (1 - Mth.abs(i)) + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
setFlap1R2Rot(Mth.clamp(-Mth.clamp(diffX, -22.5f, 22.5f) + 8 * addZ * (1 - Mth.abs(i)) + this.entityData.get(PLANE_BREAK), -22.5f, 22.5f));
if (getEnergy() > 0 && !this.level().isClientSide) {
this.consumeEnergy((int) (Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get()));
}
setFlap2LRot(Mth.clamp(Mth.clamp(diffX, -22.5f, 22.5f) - 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap2RRot(Mth.clamp(Mth.clamp(diffX, -22.5f, 22.5f) + 8 * addZ * (1 - Mth.abs(i)), -22.5f, 22.5f));
setFlap3Rot(diffY * 0.7f);
Matrix4f transform = getVehicleTransform(1);
double flapAngle = (getFlap1LRot() + getFlap1RRot()) / 2;
double flapAngle = (getFlap1LRot() + getFlap1RRot() + getFlap1L2Rot() + getFlap1R2Rot()) / 4;
Vector4f force0 = transformPosition(transform, 0, 0, 0);
Vector4f force1 = transformPosition(transform, 0, 1, 0);

View file

@ -51,7 +51,8 @@ import java.util.function.Consumer;
import java.util.stream.StreamSupport;
public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements ControllableVehicle {
public static Consumer<MobileVehicleEntity> engineSound = e -> {};
public static Consumer<MobileVehicleEntity> engineSound = e -> {
};
public static final EntityDataAccessor<Integer> CANNON_RECOIL_TIME = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Float> POWER = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.FLOAT);
@ -63,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<Float> PLANE_BREAK = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.FLOAT);
private Vec3 previousVelocity = Vec3.ZERO;
@ -113,13 +115,16 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
public float flap1LRotO;
public float flap1RRot;
public float flap1RRotO;
public float flap1L2Rot;
public float flap1L2RotO;
public float flap1R2Rot;
public float flap1R2RotO;
public float flap2LRot;
public float flap2LRotO;
public float flap2RRot;
public float flap2RRotO;
public float flap3Rot;
public float flap3RotO;
public float gearRot;
public float gearRotO;
public MobileVehicleEntity(EntityType<?> pEntityType, Level pLevel) {
@ -190,6 +195,8 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
flap1LRotO = this.getFlap1LRot();
flap1RRotO = this.getFlap1RRot();
flap1L2RotO = this.getFlap1L2Rot();
flap1R2RotO = this.getFlap1R2Rot();
flap2LRotO = this.getFlap2LRot();
flap2RRotO = this.getFlap2RRot();
flap3RotO = this.getFlap3Rot();
@ -792,6 +799,22 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
return this.flap1LRot;
}
public void setFlap1L2Rot(float pFlap1L2Rot) {
this.flap1L2Rot = pFlap1L2Rot;
}
public float getFlap1R2Rot() {
return this.flap1R2Rot;
}
public void setFlap1R2Rot(float pFlap1R2Rot) {
this.flap1R2Rot = pFlap1R2Rot;
}
public float getFlap1L2Rot() {
return this.flap1L2Rot;
}
public void setFlap1LRot(float pFlap1LRot) {
this.flap1LRot = pFlap1LRot;
}
@ -842,7 +865,8 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
.define(FIRE_ANIM, 0)
.define(COAX_HEAT, 0)
.define(DECOY_COUNT, 0)
.define(GEAR_ROT, 0);
.define(GEAR_ROT, 0)
.define(PLANE_BREAK, 0f);
}
@Override

View file

@ -6887,9 +6887,18 @@
"east": {"uv": [171, 91], "uv_size": [-8, 1]},
"south": {"uv": [172, 22], "uv_size": [-28, 1]},
"west": {"uv": [171, 90], "uv_size": [-8, 1]},
"up": {"uv": [57, 58], "uv_size": [-28, 8]}
"up": {"uv": [57, 58], "uv_size": [-28, 8]},
"down": {"uv": [50, 70], "uv_size": [-18, -4]}
}
}
]
},
{
"name": "wingLR2",
"parent": "zuoyi",
"pivot": [103.79869, 38.27137, 12.20218],
"rotation": [0, 4, 0],
"cubes": [
{
"origin": [75.44763, 36.30047, 12.02642],
"size": [56.7, 2.16, 16.308],
@ -6900,6 +6909,7 @@
"east": {"uv": [171, 93], "uv_size": [-8, 1]},
"south": {"uv": [172, 44], "uv_size": [-28, 1]},
"west": {"uv": [171, 92], "uv_size": [-8, 1]},
"up": {"uv": [50, 70], "uv_size": [-18, -4]},
"down": {"uv": [85, 66], "uv_size": [-28, -8]}
}
}
@ -7104,9 +7114,18 @@
"east": {"uv": [163, 90], "uv_size": [8, 1]},
"south": {"uv": [144, 22], "uv_size": [28, 1]},
"west": {"uv": [163, 91], "uv_size": [8, 1]},
"up": {"uv": [29, 58], "uv_size": [28, 8]}
"up": {"uv": [29, 58], "uv_size": [28, 8]},
"down": {"uv": [32, 70], "uv_size": [18, -4]}
}
}
]
},
{
"name": "wingRR2",
"parent": "youyi",
"pivot": [-103.79869, 38.27137, 12.20218],
"rotation": [0, -4, 0],
"cubes": [
{
"origin": [-132.14763, 36.30047, 12.02642],
"size": [56.7, 2.16, 16.308],
@ -7117,6 +7136,7 @@
"east": {"uv": [163, 92], "uv_size": [8, 1]},
"south": {"uv": [144, 44], "uv_size": [28, 1]},
"west": {"uv": [163, 93], "uv_size": [8, 1]},
"up": {"uv": [32, 70], "uv_size": [18, -4]},
"down": {"uv": [57, 66], "uv_size": [28, -8]}
}
}