From 6326c7fe9974a71e4860928fc59b210ade6d4325 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sat, 24 May 2025 16:55:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E6=B7=BB=E5=8A=A0=E5=B1=A5?= =?UTF-8?q?=E5=B8=A6=E9=9F=B3=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/sound/VehicleSoundInstance.java | 6 ++++-- .../superbwarfare/entity/vehicle/Bmp2Entity.java | 10 +++++----- .../superbwarfare/entity/vehicle/PrismTankEntity.java | 6 +++++- .../superbwarfare/entity/vehicle/Yx100Entity.java | 6 +++++- .../entity/vehicle/base/MobileVehicleEntity.java | 7 +++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/sound/VehicleSoundInstance.java b/src/main/java/com/atsuishio/superbwarfare/client/sound/VehicleSoundInstance.java index 4b97dc1d4..5498c3202 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/sound/VehicleSoundInstance.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/sound/VehicleSoundInstance.java @@ -104,13 +104,14 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance } public static class TrackSound extends VehicleSoundInstance { + public TrackSound(MobileVehicleEntity mobileVehicle) { super(ModSounds.TRACK_MOVE.get(), Minecraft.getInstance(), mobileVehicle); } @Override protected boolean canPlay(MobileVehicleEntity mobileVehicle) { - return true; + return mobileVehicle.engineRunning() && mobileVehicle.onGround(); } @Override @@ -125,13 +126,14 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance } public static class SwimSound extends VehicleSoundInstance { + public SwimSound(MobileVehicleEntity mobileVehicle) { super(ModSounds.VEHICLE_SWIM.get(), Minecraft.getInstance(), mobileVehicle); } @Override protected boolean canPlay(MobileVehicleEntity mobileVehicle) { - return true; + return mobileVehicle.engineRunning() && mobileVehicle.isInWater(); } @Override 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 ee421f563..b8d7b7dc1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -199,11 +199,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * getDeltaMovement().dot(getViewVector(1))))); this.setDeltaMovement(this.getDeltaMovement().multiply(f0, 0.99, f0)); - - // TODO 替换成正确的履带音效播放条件 - if (this.level().isClientSide) { - trackSound.accept(this); - } } else { this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.99, 0.99)); } @@ -730,6 +725,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit } } + @Override + public boolean hasTracks() { + return true; + } + @Override public boolean hasDecoy() { return true; 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 70fd2f610..990f821f3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -71,7 +71,6 @@ import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; import static com.atsuishio.superbwarfare.tools.SeekTool.baseFilter; -// TODO 添加正确的履带音效播放条件 public class PrismTankEntity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { public static final EntityDataAccessor CANNON_FIRE_TIME = SynchedEntityData.defineId(PrismTankEntity.class, EntityDataSerializers.INT); @@ -738,6 +737,11 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo return entityData.get(HEAT); } + @Override + public boolean hasTracks() { + return true; + } + @Override public ResourceLocation getVehicleIcon() { return Mod.loc("textures/vehicle_icon/prism_tank_icon.png"); 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 b1531d2e2..9b3b974e1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -77,7 +77,6 @@ import java.util.List; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -// TODO 添加正确的履带音效播放条件 public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { public static final EntityDataAccessor MG_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); @@ -1118,6 +1117,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti return 3; } + @Override + public boolean hasTracks() { + return true; + } + @Override public int getWeaponHeat(Player player) { if (player == getNthEntity(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 bfc5c32b9..ac406c269 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 @@ -176,6 +176,9 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements public void baseTick() { if (!this.wasEngineRunning && this.engineRunning() && this.level().isClientSide()) { engineSound.accept(this); + if (this.hasTracks()) { + trackSound.accept(this); + } } this.wasEngineRunning = this.engineRunning(); @@ -922,6 +925,10 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements compound.putBoolean("GearUp", this.entityData.get(GEAR_UP)); } + public boolean hasTracks() { + return false; + } + public boolean canCrushEntities() { return true; }