尝试添加履带音效

This commit is contained in:
17146 2025-05-24 16:55:24 +08:00 committed by Light_Quanta
parent 0c86fe5755
commit 6326c7fe99
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
5 changed files with 26 additions and 9 deletions

View file

@ -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

View file

@ -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;

View file

@ -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<Integer> 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");

View file

@ -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<Integer> 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)) {

View file

@ -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;
}