diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/A10Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/A10Renderer.java index 7ef056a3a..882066a6d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/A10Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/A10Renderer.java @@ -55,10 +55,16 @@ public class A10Renderer extends GeoEntityRenderer { 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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java index 2e10ae8f7..7a8ebeacb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -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,64 +530,22 @@ 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 (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); - - float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f)); - - float addY = Mth.clamp(Math.max((this.onGround() ? 0.1f : 0.2f) * (float) getDeltaMovement().length(), 0f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), -1.5f * (roll + 1), 1.5f * (roll + 1)); - float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.17, 0.01), 0.7f) * diffX, -3.5f, 3.5f); - float addZ = this.entityData.get(DELTA_ROT) - (this.onGround() ? 0 : 0.01f) * diffY * (float) getDeltaMovement().dot(getViewVector(1)); - - float i = getXRot() / 90; - yRotSync = addY * (1 - Mth.abs(i)) + addZ * i; - - this.setYRot(this.getYRot() + yRotSync); - if (!onGround()) { - this.setXRot(Mth.clamp(this.getXRot() + addX, -80, 80)); - 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)); - - // 起落架 - if (!SeekTool.isOnGround(this, 15)) { - flyTime = Math.min(flyTime + 1, 20); - } - - if (SeekTool.isOnGround(this, 15) && fly) { - flyTime = Math.max(flyTime - 1, 0); - } - - if (!fly && flyTime == 10) { - fly = true; - } - - if (fly && flyTime == 0) { - fly = false; - } - - if (fly) { - 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)); - } } } else if (!onGround()) { this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0003f, 0.02f)); @@ -601,13 +559,64 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity 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)); + + float addY = Mth.clamp(Math.max((this.onGround() ? 0.1f : 0.2f) * (float) getDeltaMovement().length(), 0f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), -1.5f * (roll + 1), 1.5f * (roll + 1)); + float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.17, 0.01), 0.7f) * diffX, -3.5f, 3.5f); + float addZ = this.entityData.get(DELTA_ROT) - (this.onGround() ? 0 : 0.01f) * diffY * (float) getDeltaMovement().dot(getViewVector(1)); + + float i = getXRot() / 90; + yRotSync = addY * (1 - Mth.abs(i)) + addZ * i; + + this.setYRot(this.getYRot() + yRotSync); + if (!onGround()) { + this.setXRot(Mth.clamp(this.getXRot() + addX, -80, 80)); + this.setZRot(this.getRoll() - addZ * (1 - Mth.abs(i))); + } + + this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER)); + + // 起落架 + if (!SeekTool.isOnGround(this, 15)) { + flyTime = Math.min(flyTime + 1, 20); + } + + if (SeekTool.isOnGround(this, 15) && fly) { + flyTime = Math.max(flyTime - 1, 0); + } + + if (!fly && flyTime == 10) { + fly = true; + } + + if (fly && flyTime == 0) { + fly = false; + } + + if (fly) { + 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)); + } + + 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)); + + 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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java index 9f61959c2..2372e8fba 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java @@ -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 engineSound = e -> {}; + public static Consumer engineSound = e -> { + }; public static final EntityDataAccessor CANNON_RECOIL_TIME = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor POWER = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.FLOAT); @@ -63,6 +64,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor DECOY_COUNT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor GEAR_ROT = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor 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 diff --git a/src/main/resources/assets/superbwarfare/geo/a10.geo.json b/src/main/resources/assets/superbwarfare/geo/a10.geo.json index dec482372..4eb0ae426 100644 --- a/src/main/resources/assets/superbwarfare/geo/a10.geo.json +++ b/src/main/resources/assets/superbwarfare/geo/a10.geo.json @@ -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]} } }