From 02a396a6e41b6713b5fdfc5c26e719ea946310ae Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Sat, 21 Jun 2025 17:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E4=BB=B6=E5=8F=97?= =?UTF-8?q?=E6=8D=9F=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=BD=AE?= =?UTF-8?q?=E5=AD=90/=E5=B1=A5=E5=B8=A6=E5=8F=97=E6=8D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/overlay/VehicleHudOverlay.java | 18 ++- .../projectile/JavelinMissileEntity.java | 4 +- .../entity/vehicle/Bmp2Entity.java | 21 +++- .../entity/vehicle/Lav150Entity.java | 25 +++- .../entity/vehicle/PrismTankEntity.java | 22 +++- .../entity/vehicle/Yx100Entity.java | 63 ++++++++-- .../entity/vehicle/base/VehicleEntity.java | 112 ++++++++++++++---- .../data/superbwarfare/guns/javelin.json | 2 +- .../data/superbwarfare/vehicles/bmp_2.json | 2 +- .../data/superbwarfare/vehicles/lav_150.json | 4 +- 10 files changed, 217 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java index 2f22cf5fc..90127b287 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleHudOverlay.java @@ -48,7 +48,7 @@ import java.util.concurrent.atomic.AtomicReference; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*; import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.DECOY_COUNT; -import static com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity.TURRET_DAMAGED_TIME; +import static com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity.*; @OnlyIn(Dist.CLIENT) public class VehicleHudOverlay implements LayeredDraw.Layer { @@ -207,10 +207,20 @@ public class VehicleHudOverlay implements LayeredDraw.Layer { } //左轮 ResourceLocation left_wheel; - left_wheel = Mod.loc("textures/screens/land/left_wheel.png"); + if (mobileVehicle.getEntityData().get(L_WHEEL_DAMAGED)) { + left_wheel = Mod.loc("textures/screens/land/left_wheel_damaged.png"); + } else { + left_wheel = Mod.loc("textures/screens/land/left_wheel.png"); + } + //右轮 ResourceLocation right_wheel; - right_wheel = Mod.loc("textures/screens/land/right_wheel.png"); + if (mobileVehicle.getEntityData().get(R_WHEEL_DAMAGED)) { + right_wheel = Mod.loc("textures/screens/land/right_wheel_damaged.png"); + } else { + right_wheel = Mod.loc("textures/screens/land/right_wheel.png"); + } + //引擎 ResourceLocation engine; engine = Mod.loc("textures/screens/land/engine.png"); @@ -226,7 +236,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer { // 炮塔损伤 ResourceLocation barrel; - if (mobileVehicle.getEntityData().get(TURRET_DAMAGED_TIME) > 0) { + if (mobileVehicle.getEntityData().get(TURRET_DAMAGED)) { barrel = Mod.loc("textures/screens/land/line_damaged.png"); } else { barrel = Mod.loc("textures/screens/land/line.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index 280eb6c9c..34b009d58 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -188,9 +188,9 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo } if (entity instanceof Monster monster) { - monster.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), (entityData.get(TOP) ? 1.3f : 1f) * this.damage * damageMultiplier); + monster.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), (entityData.get(TOP) ? 1.25f : 1f) * this.damage * damageMultiplier); } else { - entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), (entityData.get(TOP) ? 1.3f : 1f) * this.damage); + entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), (entityData.get(TOP) ? 1.25f : 1f) * this.damage); } if (entity instanceof LivingEntity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 53d28f1a3..90668753d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -82,8 +82,8 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit super(type, world); this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.875f, 3.90625f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), OBB.Part.BODY); - this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.BODY); - this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.BODY); + this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), OBB.Part.TURRET); } @@ -444,7 +444,22 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit setLeftTrack((float) ((getLeftTrack() - 1.9 * Math.PI * s0) + Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); setRightTrack((float) ((getRightTrack() - 1.9 * Math.PI * s0) - Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); - this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT))); + int i; + + if (entityData.get(L_WHEEL_DAMAGED) && entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.93f); + i = 0; + } else if (entityData.get(L_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = 3; + } else if (entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = -3; + } else { + i = 0; + } + + this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); if (this.isInWater() || onGround()) { float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power))); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 6ecd6852a..d2cd34dfd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -69,10 +69,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt public Lav150Entity(EntityType type, Level world) { super(type, world); - this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.BODY); - this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.BODY); - this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.BODY); - this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.BODY); + this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.3f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); + this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.3f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.3f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.3f, 0.75f, 0.75f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.90625f, 2.4375f), new Quaternionf(), OBB.Part.BODY); this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.53125f, 0.34375f), new Quaternionf(), OBB.Part.BODY); this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.625f, 0.53125f), new Quaternionf(), OBB.Part.BODY); @@ -326,7 +326,22 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt this.setRudderRot(Mth.clamp(this.getRudderRot() - this.entityData.get(DELTA_ROT), -0.8f, 0.8f) * 0.75f); - this.setYRot((float) (this.getYRot() - Math.max((isInWater() && !onGround() ? 5 : 10) * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1))); + int i; + + if (entityData.get(L_WHEEL_DAMAGED) && entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.93f); + i = 0; + } else if (entityData.get(L_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = 3; + } else if (entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = -3; + } else { + i = 0; + } + + this.setYRot((float) (this.getYRot() - Math.max((isInWater() && !onGround() ? 5 : 10) * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1) - i * s0)); if (this.isInWater() || onGround()) { float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.05f : (isInWater() && !onGround() ? 0.3f : 1)) * power))); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java index 3c41a38c8..15895b327 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -91,8 +91,8 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo this.noCulling = true; this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.8125f, 3.96875f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.5f, 0.375f), new Quaternionf(), OBB.Part.BODY); - this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.BODY); - this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.BODY); + this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.375f, 0.28125f, 1.375f), new Quaternionf(), OBB.Part.BODY); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.4375f, 0.90625f, 1.21875f), new Quaternionf(), OBB.Part.TURRET); } @@ -508,7 +508,23 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo setLeftTrack((float) ((getLeftTrack() - 1.9 * Math.PI * s0) + Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); setRightTrack((float) ((getRightTrack() - 1.9 * Math.PI * s0) - Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); - this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT))); + int i; + + if (entityData.get(L_WHEEL_DAMAGED) && entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.93f); + i = 0; + } else if (entityData.get(L_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = 3; + } else if (entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = -3; + } else { + i = 0; + } + + this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); + if (this.isInWater() || onGround()) { float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power))); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index dfdf7ee30..3a72e3f46 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -96,8 +96,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti super(type, world); this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.71875f, 4f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.59375f, 0.65625f), new Quaternionf(), OBB.Part.BODY); - this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), OBB.Part.BODY); - this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), OBB.Part.BODY); + this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.5625f, 2.1875f), new Quaternionf(), OBB.Part.TURRET); this.obbTurret2 = new OBB(this.position().toVector3f(), new Vector3f(1.625f, 0.40625f, 0.59375f), new Quaternionf(), OBB.Part.TURRET); } @@ -331,6 +331,34 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.refreshDimensions(); } + @Override + public void partDamaged() { + if (entityData.get(TURRET_HEALTH) < 0) { + entityData.set(TURRET_DAMAGED, true); + } + if (entityData.get(TURRET_HEALTH) > 80) { + entityData.set(TURRET_DAMAGED, false); + } + + if (entityData.get(L_WHEEL_HEALTH) < 0) { + entityData.set(L_WHEEL_DAMAGED, true); + } + if (entityData.get(L_WHEEL_HEALTH) > 80) { + entityData.set(L_WHEEL_DAMAGED, false); + } + + if (entityData.get(R_WHEEL_HEALTH) < 0) { + entityData.set(R_WHEEL_DAMAGED, true); + } + if (entityData.get(R_WHEEL_HEALTH) > 80) { + entityData.set(R_WHEEL_DAMAGED, false); + } + + entityData.set(TURRET_HEALTH, Math.min(entityData.get(TURRET_HEALTH) + 0.5f, 100)); + entityData.set(L_WHEEL_HEALTH, Math.min(entityData.get(L_WHEEL_HEALTH) + 0.5f, 100)); + entityData.set(R_WHEEL_HEALTH, Math.min(entityData.get(R_WHEEL_HEALTH) + 0.5f, 100)); + } + @Override public void terrainCompact(float w, float l) { if (onGround()) { @@ -721,7 +749,22 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti setLeftTrack((float) ((getLeftTrack() - 1.5 * Math.PI * s0) + Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); setRightTrack((float) ((getRightTrack() - 1.5 * Math.PI * s0) - Mth.clamp(0.4f * Math.PI * this.entityData.get(DELTA_ROT), -5f, 5f))); - this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT))); + int i; + + if (entityData.get(L_WHEEL_DAMAGED) && entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.93f); + i = 0; + } else if (entityData.get(L_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = 3; + } else if (entityData.get(R_WHEEL_DAMAGED)) { + this.entityData.set(POWER, this.entityData.get(POWER) * 0.975f); + i = -3; + } else { + i = 0; + } + + this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); if (this.isInWater() || onGround()) { float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power))); @@ -1285,14 +1328,16 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti return Mod.loc("textures/gui/vehicle/type/land.png"); } - @Override - public float turretDamagedMin() { - return 75; + public float getTurretMaxHealth() { + return 100; } - @Override - public float turretDamagedMultiply() { - return 2; + public float getLeftWheelMaxHealth() { + return 100; + } + + public float getRightWheelMaxHealth() { + return 100; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 24c43cfa6..de1d5f536 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -89,9 +89,14 @@ public abstract class VehicleEntity extends Entity { public static final EntityDataAccessor MOUSE_SPEED_Y = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor> SELECTED_WEAPON = SynchedEntityData.defineId(VehicleEntity.class, ModSerializers.INT_LIST_SERIALIZER.get()); public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor TURRET_DAMAGED_TIME = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor L_WHEEL_DAMAGED_TIME = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor R_WHEEL_DAMAGED_TIME = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); + + public static final EntityDataAccessor TURRET_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor L_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor R_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); + + public static final EntityDataAccessor TURRET_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); + public static final EntityDataAccessor L_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); + public static final EntityDataAccessor R_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public VehicleWeapon[][] availableWeapons; @@ -303,9 +308,12 @@ public abstract class VehicleEntity extends Entity { .define(MOUSE_SPEED_X, 0f) .define(MOUSE_SPEED_Y, 0f) .define(HEAT, 0) - .define(TURRET_DAMAGED_TIME, 0) - .define(L_WHEEL_DAMAGED_TIME, 0) - .define(R_WHEEL_DAMAGED_TIME, 0) + .define(TURRET_HEALTH, getTurretMaxHealth()) + .define(L_WHEEL_HEALTH, getLeftWheelMaxHealth()) + .define(R_WHEEL_HEALTH, getRightWheelMaxHealth()) + .define(TURRET_DAMAGED, false) + .define(L_WHEEL_DAMAGED, false) + .define(R_WHEEL_DAMAGED, false) .define(SELECTED_WEAPON, IntList.of(new int[this.getMaxPassengers()])); // 怎么还不给玩动态注册了(恼) } @@ -327,9 +335,14 @@ public abstract class VehicleEntity extends Entity { this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker")); this.entityData.set(LAST_DRIVER_UUID, compound.getString("LastDriver")); this.entityData.set(HEALTH, compound.getFloat("Health")); - this.entityData.set(TURRET_DAMAGED_TIME, compound.getInt("TurretDamagedTime")); - this.entityData.set(L_WHEEL_DAMAGED_TIME, compound.getInt("LWheelDamagedTime")); - this.entityData.set(R_WHEEL_DAMAGED_TIME, compound.getInt("RWheelDamagedTime")); + + this.entityData.set(TURRET_HEALTH, compound.getFloat("TurretHealth")); + this.entityData.set(L_WHEEL_HEALTH, compound.getFloat("LeftWheelHealth")); + this.entityData.set(R_WHEEL_HEALTH, compound.getFloat("RightWheelHealth")); + + this.entityData.set(TURRET_DAMAGED, compound.getBoolean("TurretDamaged")); + this.entityData.set(L_WHEEL_DAMAGED, compound.getBoolean("LeftDamaged")); + this.entityData.set(R_WHEEL_DAMAGED, compound.getBoolean("RightDamaged")); if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { var selected = compound.getIntArray("SelectedWeapon"); @@ -348,9 +361,14 @@ public abstract class VehicleEntity extends Entity { compound.putFloat("Health", this.entityData.get(HEALTH)); compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID)); compound.putString("LastDriver", this.entityData.get(LAST_DRIVER_UUID)); - compound.putInt("TurretDamagedTime", this.entityData.get(TURRET_DAMAGED_TIME)); - compound.putInt("LWheelDamagedTime", this.entityData.get(L_WHEEL_DAMAGED_TIME)); - compound.putInt("RWheelDamagedTime", this.entityData.get(R_WHEEL_DAMAGED_TIME)); + + compound.putFloat("TurretHealth", this.entityData.get(TURRET_HEALTH)); + compound.putFloat("LeftWheelHealth", this.entityData.get(L_WHEEL_HEALTH)); + compound.putFloat("RightWheelHealth", this.entityData.get(R_WHEEL_HEALTH)); + + compound.putBoolean("TurretDamaged", this.entityData.get(TURRET_DAMAGED)); + compound.putBoolean("LeftWheelDamaged", this.entityData.get(L_WHEEL_DAMAGED)); + compound.putBoolean("RightWheelDamaged", this.entityData.get(R_WHEEL_DAMAGED)); if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { compound.putIntArray("SelectedWeapon", this.entityData.get(SELECTED_WEAPON)); @@ -450,8 +468,16 @@ public abstract class VehicleEntity extends Entity { if (source.getDirectEntity() instanceof Projectile projectile) { OBBHitter accessor = OBBHitter.getInstance(projectile); //炮塔损伤 - if (this instanceof OBBEntity obbEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.TURRET && computedAmount > turretDamagedMin()) { - entityData.set(TURRET_DAMAGED_TIME, (int) (entityData.get(TURRET_DAMAGED_TIME) + computedAmount * turretDamagedMultiply())); + if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.TURRET) { + entityData.set(TURRET_HEALTH, entityData.get(TURRET_HEALTH) - computedAmount); + } + //左轮损伤 + if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.WHEEL_LEFT) { + entityData.set(L_WHEEL_HEALTH, entityData.get(L_WHEEL_HEALTH) - computedAmount); + } + //右轮损伤 + if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.WHEEL_RIGHT) { + entityData.set(R_WHEEL_HEALTH, entityData.get(R_WHEEL_HEALTH) - computedAmount); } // System.out.println(accessor.sbw$getCurrentHitPart()); } @@ -521,6 +547,18 @@ public abstract class VehicleEntity extends Entity { return data().maxHealth(); } + public float getTurretMaxHealth() { + return 50; + } + + public float getLeftWheelMaxHealth() { + return 50; + } + + public float getRightWheelMaxHealth() { + return 50; + } + @Override public boolean canBeCollidedWith() { return true; @@ -655,13 +693,44 @@ public abstract class VehicleEntity extends Entity { clearArrow(); + // 炮塔损毁特效 + turretDamagedEffect(); + + //部件血量 partDamaged(); + this.refreshDimensions(); } public void partDamaged() { - // 炮塔损毁特效 - if (entityData.get(TURRET_DAMAGED_TIME) > 0) { + if (entityData.get(TURRET_HEALTH) < 0) { + entityData.set(TURRET_DAMAGED, true); + } + if (entityData.get(TURRET_HEALTH) > 40) { + entityData.set(TURRET_DAMAGED, false); + } + + if (entityData.get(L_WHEEL_HEALTH) < 0) { + entityData.set(L_WHEEL_DAMAGED, true); + } + if (entityData.get(L_WHEEL_HEALTH) > 40) { + entityData.set(L_WHEEL_DAMAGED, false); + } + + if (entityData.get(R_WHEEL_HEALTH) < 0) { + entityData.set(R_WHEEL_DAMAGED, true); + } + if (entityData.get(R_WHEEL_HEALTH) > 40) { + entityData.set(R_WHEEL_DAMAGED, false); + } + + entityData.set(TURRET_HEALTH, Math.min(entityData.get(TURRET_HEALTH) + 0.25f, 50)); + entityData.set(L_WHEEL_HEALTH, Math.min(entityData.get(L_WHEEL_HEALTH) + 0.25f, 50)); + entityData.set(R_WHEEL_HEALTH, Math.min(entityData.get(R_WHEEL_HEALTH) + 0.25f, 50)); + } + + public void turretDamagedEffect() { + if (entityData.get(TURRET_DAMAGED)) { List entities = getPlayer(level()); for (var e : entities) { if (e instanceof ServerPlayer player) { @@ -673,7 +742,6 @@ public abstract class VehicleEntity extends Entity { } } } - entityData.set(TURRET_DAMAGED_TIME, entityData.get(TURRET_DAMAGED_TIME) - 1); } } @@ -738,7 +806,7 @@ public abstract class VehicleEntity extends Entity { this.turretTurnSound(diffX, diffY, 0.95f); - if (entityData.get(TURRET_DAMAGED_TIME) > 0) { + if (entityData.get(TURRET_DAMAGED)) { ySpeed *= 0.2f; xSpeed *= 0.2f; } @@ -1083,14 +1151,6 @@ public abstract class VehicleEntity extends Entity { super.addDeltaMovement(pAddend); } - public float turretDamagedMin() { - return 30; - } - - public float turretDamagedMultiply() { - return 4; - } - /** * 玩家在载具上的灵敏度调整 * diff --git a/src/main/resources/data/superbwarfare/guns/javelin.json b/src/main/resources/data/superbwarfare/guns/javelin.json index 3c860798e..8238a71c5 100644 --- a/src/main/resources/data/superbwarfare/guns/javelin.json +++ b/src/main/resources/data/superbwarfare/guns/javelin.json @@ -5,7 +5,7 @@ "Magazine": 1, "Weight": 10, "EmptyReloadTime": 78, - "Damage": 700, + "Damage": 500, "ExplosionDamage": 120, "ExplosionRadius": 9, "AmmoType": "superbwarfare:javelin_missile", diff --git a/src/main/resources/data/superbwarfare/vehicles/bmp_2.json b/src/main/resources/data/superbwarfare/vehicles/bmp_2.json index 3dbd7cee0..19393606b 100644 --- a/src/main/resources/data/superbwarfare/vehicles/bmp_2.json +++ b/src/main/resources/data/superbwarfare/vehicles/bmp_2.json @@ -71,7 +71,7 @@ }, { "Type": "Multiply", - "Value": 1.5, + "Value": 1.35, "Source": "superbwarfare:cannon_fire" }, { diff --git a/src/main/resources/data/superbwarfare/vehicles/lav_150.json b/src/main/resources/data/superbwarfare/vehicles/lav_150.json index 6da348210..8caf261d0 100644 --- a/src/main/resources/data/superbwarfare/vehicles/lav_150.json +++ b/src/main/resources/data/superbwarfare/vehicles/lav_150.json @@ -1,6 +1,6 @@ { "ID": "superbwarfare:lav_150", - "MaxHealth": 250, + "MaxHealth": 270, "MaxEnergy": 5000000, "UpStep": 1.5, "Mass": 13.6, @@ -66,7 +66,7 @@ }, { "Type": "Multiply", - "Value": 1.5, + "Value": 1.4, "Source": "superbwarfare:cannon_fire" }, {