diff --git a/src/main/java/com/atsuishio/superbwarfare/client/VehicleSoundInstance.java b/src/main/java/com/atsuishio/superbwarfare/client/VehicleSoundInstance.java index 67ea2562a..f0fe107c3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/VehicleSoundInstance.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/VehicleSoundInstance.java @@ -1,11 +1,12 @@ package com.atsuishio.superbwarfare.client; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; +import com.atsuishio.superbwarfare.init.ModSounds; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; -import org.joml.Math; +import net.minecraft.util.Mth; public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance { private final Minecraft client; @@ -27,8 +28,6 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance protected abstract float getPitch(MobileVehicleEntity mobileVehicle); protected abstract float getVolume(MobileVehicleEntity mobileVehicle); - protected abstract float getRadius(MobileVehicleEntity mobileVehicle); - @Override public void tick() { var player = this.client.player; @@ -49,9 +48,7 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance this.fade++; } - float distanceReduce = Math.max((1 - player.distanceTo(mobileVehicle) / getRadius(mobileVehicle)), 0); - - this.volume = this.getVolume(this.mobileVehicle) * fade * distanceReduce * distanceReduce; + this.volume = this.getVolume(this.mobileVehicle) * fade; this.x = this.mobileVehicle.getX(); this.y = this.mobileVehicle.getY(); @@ -69,11 +66,6 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance } } - @Override - public Attenuation getAttenuation() { - return Attenuation.NONE; - } - public static class EngineSound extends VehicleSoundInstance { public EngineSound(MobileVehicleEntity mobileVehicle, SoundEvent soundEvent) { super(soundEvent, Minecraft.getInstance(), mobileVehicle); @@ -93,10 +85,26 @@ public abstract class VehicleSoundInstance extends AbstractTickableSoundInstance protected float getVolume(MobileVehicleEntity mobileVehicle) { return mobileVehicle.getEngineSoundVolume(); } + } + + public static class TrackSound extends VehicleSoundInstance { + public TrackSound(MobileVehicleEntity mobileVehicle) { + super(ModSounds.TRACK_MOVE.get(), Minecraft.getInstance(), mobileVehicle); + } @Override - protected float getRadius(MobileVehicleEntity mobileVehicle) { - return mobileVehicle.getEngineSoundRadius(); + protected boolean canPlay(MobileVehicleEntity mobileVehicle) { + return true; + } + + @Override + protected float getPitch(MobileVehicleEntity mobileVehicle) { + return 1; + } + + @Override + protected float getVolume(MobileVehicleEntity mobileVehicle) { + return (float) Mth.lerp(Mth.clamp(mobileVehicle.getDeltaMovement().length(), 0F, 0.3F), 0.0F, 0.3F); } } } 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 05877e997..0757678d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -84,7 +84,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity @Override protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) { - this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.5), random.nextFloat() * 0.1f + 1f); + this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.2), random.nextFloat() * 0.1f + 1f); } @Override @@ -132,7 +132,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity super.baseTick(); float f; - f = (float) Mth.clamp(Math.max((onGround() ? 0.785f : 0.79f) - 0.013 * getDeltaMovement().length(), 0.5) + 0.031f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); + f = (float) Mth.clamp(Math.max((onGround() ? 0.785f : 0.79f) - 0.01 * getDeltaMovement().length(), 0.5) + 0.031f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90; @@ -311,11 +311,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity return ModSounds.A_10_ENGINE.get(); } - @Override - public int getEngineSoundRadius() { - return 192; - } - @Override public float getEngineSoundVolume() { return entityData.get(POWER) * 1.5f; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index aea469229..0e5109171 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -362,14 +362,9 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity return ModSounds.HELICOPTER_ENGINE.get(); } - @Override - public int getEngineSoundRadius() { - return 192; - } - @Override public float getEngineSoundVolume() { - return entityData.get(PROPELLER_ROT) * 1.5f; + return entityData.get(PROPELLER_ROT) * 2f; } protected void clampRotation(Entity entity) { 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 68d07ceae..0feabb857 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -6,10 +6,7 @@ import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity; import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity; import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; -import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.*; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallCannonShellWeapon; @@ -70,7 +67,8 @@ import java.util.List; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { +public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { + public static final EntityDataAccessor CANNON_FIRE_TIME = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_MISSILE = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor MISSILE_COUNT = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT); @@ -186,7 +184,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit @Override @ParametersAreNonnullByDefault protected void playStepSound(BlockPos pPos, BlockState pState) { - this.playSound(ModSounds.BMP_STEP.get(), Mth.abs(this.entityData.get(POWER)) * 8, random.nextFloat() * 0.15f + 1f); + this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.15), random.nextFloat() * 0.15f + 1.05f); } @Override @@ -501,6 +499,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit return ModSounds.BMP_ENGINE.get(); } + @Override + public float getEngineSoundVolume() { + return Math.max(Mth.abs(entityData.get(POWER)), Mth.abs(0.1f * this.entityData.get(DELTA_ROT))) * 2.5f; + } + @Override public void positionRider(@NotNull Entity passenger, @NotNull MoveFunction callback) { // From Immersive_Aircraft 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 8db8db47a..cd1ed7fd1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -121,7 +121,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt @Override @ParametersAreNonnullByDefault protected void playStepSound(BlockPos pPos, BlockState pState) { - this.playSound(ModSounds.BMP_STEP.get(), Mth.abs(this.entityData.get(POWER)) * 3, random.nextFloat() * 0.15f + 1.05f); + this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.15f + 1.05f); } @Override @@ -385,6 +385,11 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt return ModSounds.LAV_ENGINE.get(); } + @Override + public float getEngineSoundVolume() { + return Mth.abs(entityData.get(POWER)) * 2f; + } + @Override public void positionRider(@NotNull Entity passenger, @NotNull MoveFunction callback) { // From Immersive_Aircraft 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 78b8d2f0c..511c4378a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -5,10 +5,7 @@ import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity; import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; -import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.*; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; @@ -73,7 +70,7 @@ import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; import static com.atsuishio.superbwarfare.tools.SeekTool.baseFilter; -public class PrismTankEntity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { +public class PrismTankEntity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { public static final EntityDataAccessor CANNON_FIRE_TIME = SynchedEntityData.defineId(PrismTankEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LASER_LENGTH = SynchedEntityData.defineId(PrismTankEntity.class, EntityDataSerializers.FLOAT); @@ -164,7 +161,7 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo @Override protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) { - this.playSound(ModSounds.BMP_STEP.get(), Mth.abs(this.entityData.get(POWER)) * 8, random.nextFloat() * 0.15f + 1f); + this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.15), random.nextFloat() * 0.15f + 1.05f); } @Override @@ -545,7 +542,12 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo @Override public SoundEvent getEngineSound() { - return ModSounds.BMP_ENGINE.get(); + return ModSounds.PRISM_ENGINE.get(); + } + + @Override + public float getEngineSoundVolume() { + return Math.max(Mth.abs(entityData.get(POWER)), Mth.abs(0.1f * this.entityData.get(DELTA_ROT))) * 2.5f; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java index 8772e46a0..c8eea426a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java @@ -237,11 +237,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity { return SoundEvents.EMPTY; } - @Override - public int getEngineSoundRadius() { - return 64; - } - @Override public float getEngineSoundVolume() { return entityData.get(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 a47453d32..a95bd7dd2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -4,10 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.*; -import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; -import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.*; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.CannonShellWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; @@ -76,7 +73,7 @@ import java.util.List; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { +public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { public static final EntityDataAccessor MG_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_AP = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_HE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); @@ -261,7 +258,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) { - this.playSound(ModSounds.BMP_STEP.get(), Mth.abs(this.entityData.get(POWER)) * 8, random.nextFloat() * 0.15f + 1f); + this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.15), random.nextFloat() * 0.15f + 1.05f); } @Override @@ -781,7 +778,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override public SoundEvent getEngineSound() { - return ModSounds.BMP_ENGINE.get(); + return ModSounds.YX_100_ENGINE.get(); + } + + @Override + public float getEngineSoundVolume() { + return Math.max(Mth.abs(entityData.get(POWER)), Mth.abs(0.1f * this.entityData.get(DELTA_ROT))) * 2.5f; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java new file mode 100644 index 000000000..1c75fd79f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java @@ -0,0 +1,4 @@ +package com.atsuishio.superbwarfare.entity.vehicle.base; + +public interface TrackEntity { +} diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java index 18ee59cc3..85cac4dda 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java @@ -2,8 +2,9 @@ package com.atsuishio.superbwarfare.event; import com.atsuishio.superbwarfare.client.VehicleSoundInstance; import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity; -import com.atsuishio.superbwarfare.entity.vehicle.*; +import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.TrackEntity; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.tools.NBTTool; @@ -12,7 +13,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvent; -import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; @@ -25,20 +25,18 @@ import org.joml.Math; import java.util.List; -import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.DELTA_ROT; -import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.POWER; - @EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT) public class ClientSoundHandler { @SubscribeEvent public static void handleJoinLevelEvent(EntityJoinLevelEvent event) { if (event.getLevel().isClientSide) { - com.atsuishio.superbwarfare.Mod.queueClientWork(5, () -> { - if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle) { - Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound())); - } - }); + if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle) { + Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound())); + } + if (event.getEntity() instanceof MobileVehicleEntity mobileVehicle && mobileVehicle instanceof TrackEntity) { + Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(mobileVehicle)); + } } } @@ -60,46 +58,7 @@ public class ClientSoundHandler { var engineSoundPos = new Vec3(listener.x + toVec.x, listener.y + toVec.y, listener.z + toVec.z); SoundEvent engineSound = mobileVehicle.getEngineSound(); float distanceReduce; -// if (e instanceof Ah6Entity ah6Entity) { -// distanceReduce = (float) Math.max((1 - distance / 128), 0); -// if (player.getVehicle() == ah6Entity) { -// player.playSound(ModSounds.HELICOPTER_ENGINE_1P.get(), 2 * (mobileVehicle.getEntityData().get(PROPELLER_ROT) - 0.012f), (float) ((2 * Math.random() - 1) * 0.1f + 1.0f)); -// } else { -// player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (mobileVehicle.getEntityData().get(PROPELLER_ROT) - 0.012f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); -// } -// } - if (e instanceof Lav150Entity lav150) { - distanceReduce = (float) Math.max((1 - distance / 64), 0); - if (player.getVehicle() == lav150) { - player.playSound(ModSounds.LAV_ENGINE_1P.get(), 1 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) - 0.006f), (float) ((2 * Math.random() - 1) * 0.1f + 0.95f)); - } else { - player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) - 0.006f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); - } - } - if (e instanceof Bmp2Entity bmp2) { - distanceReduce = (float) Math.max((1 - distance / 64), 0); - if (player.getVehicle() == bmp2) { - player.playSound(ModSounds.BMP_ENGINE_1P.get(), 1 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f), (float) ((2 * Math.random() - 1) * 0.1f + 0.95f)); - } else { - player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); - } - } - if (e instanceof Yx100Entity yx100) { - distanceReduce = (float) Math.max((1 - distance / 64), 0); - if (player.getVehicle() == yx100) { - player.playSound(ModSounds.BMP_ENGINE_1P.get(), 1 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f), (float) ((2 * Math.random() - 1) * 0.1f + 0.95f)); - } else { - player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); - } - } - if (e instanceof PrismTankEntity prismTank) { - distanceReduce = (float) Math.max((1 - distance / 64), 0); - if (player.getVehicle() == prismTank) { - player.playSound(ModSounds.BMP_ENGINE_1P.get(), 1 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f), (float) ((2 * Math.random() - 1) * 0.1f + 0.95f)); - } else { - player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); - } - } + if (e instanceof DroneEntity) { distanceReduce = (float) Math.max((1 - distance / 64), 0); ItemStack stack = player.getMainHandItem(); @@ -110,14 +69,6 @@ public class ClientSoundHandler { player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), e.onGround() ? 0 : distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.002f + 1.05), false); } } -// if (e instanceof A10Entity a10Entity) { -// distanceReduce = (float) Math.max((1 - distance / 128), 0); -// if (player.getVehicle() == a10Entity) { -// player.playSound(ModSounds.A_10_ENGINE_1P.get(), 2 * (mobileVehicle.getEntityData().get(POWER) - 0.012f), (float) ((2 * Math.random() - 1) * 0.1f + 1.0f)); -// } else { -// player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (mobileVehicle.getEntityData().get(POWER) - 0.012f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false); -// } -// } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 196df977a..2446b3e01 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -384,7 +384,6 @@ public class ModSounds { public static final DeferredHolder HELICOPTER_ENGINE_START = REGISTRY.register("helicopter_engine_start", () -> SoundEvent.createVariableRangeEvent(Mod.loc("helicopter_engine_start"))); public static final DeferredHolder HELICOPTER_ENGINE = REGISTRY.register("helicopter_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("helicopter_engine"))); - public static final DeferredHolder HELICOPTER_ENGINE_1P = REGISTRY.register("helicopter_engine_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("helicopter_engine_1p"))); public static final DeferredHolder HELICOPTER_CANNON_FIRE_1P = REGISTRY.register("heli_cannon_fire_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("heli_cannon_fire_1p"))); public static final DeferredHolder HELICOPTER_CANNON_FIRE_3P = REGISTRY.register("heli_cannon_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("heli_cannon_fire_3p"))); public static final DeferredHolder HELICOPTER_CANNON_FAR = REGISTRY.register("heli_cannon_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("heli_cannon_far"))); @@ -407,16 +406,13 @@ public class ModSounds { public static final DeferredHolder LAV_CANNON_FAR = REGISTRY.register("lav_cannon_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("lav_far"))); public static final DeferredHolder LAV_CANNON_VERYFAR = REGISTRY.register("lav_cannon_veryfar", () -> SoundEvent.createVariableRangeEvent(Mod.loc("lav_veryfar"))); public static final DeferredHolder LAV_ENGINE = REGISTRY.register("lav_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("lav_engine"))); - public static final DeferredHolder LAV_ENGINE_1P = REGISTRY.register("lav_engine_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("lav_engine_1p"))); public static final DeferredHolder COAX_FIRE_1P = REGISTRY.register("coax_fire_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("coax_fire_1p"))); public static final DeferredHolder BMP_CANNON_FIRE_1P = REGISTRY.register("bmp_cannon_fire_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_fire_1p"))); public static final DeferredHolder BMP_CANNON_FIRE_3P = REGISTRY.register("bmp_cannon_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_fire_3p"))); public static final DeferredHolder BMP_ENGINE = REGISTRY.register("bmp_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_engine"))); - public static final DeferredHolder BMP_ENGINE_1P = REGISTRY.register("bmp_engine_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_engine_1p"))); public static final DeferredHolder BMP_MISSILE_FIRE_1P = REGISTRY.register("bmp_missile_fire_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_missile_fire_1p"))); public static final DeferredHolder BMP_MISSILE_FIRE_3P = REGISTRY.register("bmp_missile_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_missile_fire_3p"))); public static final DeferredHolder BMP_MISSILE_RELOAD = REGISTRY.register("bmp_missile_reload", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_missile_reload"))); - public static final DeferredHolder BMP_STEP = REGISTRY.register("bmp_step", () -> SoundEvent.createVariableRangeEvent(Mod.loc("bmp_step"))); public static final DeferredHolder WHEEL_STEP = REGISTRY.register("wheel_step", () -> SoundEvent.createVariableRangeEvent(Mod.loc("wheel_step"))); public static final DeferredHolder LASER_TOWER_SHOOT = REGISTRY.register("laser_tower_shoot", () -> SoundEvent.createVariableRangeEvent(Mod.loc("laser_tower_shoot"))); public static final DeferredHolder YX_100_RELOAD = REGISTRY.register("yx_100_reload", () -> SoundEvent.createVariableRangeEvent(Mod.loc("yx_100_reload"))); @@ -424,6 +420,7 @@ public class ModSounds { public static final DeferredHolder YX_100_FIRE_3P = REGISTRY.register("yx_100_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("yx_100_fire_3p"))); public static final DeferredHolder YX_100_FAR = REGISTRY.register("yx_100_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("yx_100_far"))); public static final DeferredHolder YX_100_VERYFAR = REGISTRY.register("yx_100_veryfar", () -> SoundEvent.createVariableRangeEvent(Mod.loc("yx_100_veryfar"))); + public static final DeferredHolder YX_100_ENGINE = REGISTRY.register("yx_100_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("yx_100_engine"))); public static final DeferredHolder TURRET_TURN = REGISTRY.register("turret_turn", () -> SoundEvent.createVariableRangeEvent(Mod.loc("turret_turn"))); public static final DeferredHolder C4_BEEP = REGISTRY.register("c4_beep", () -> SoundEvent.createVariableRangeEvent(Mod.loc("c4_beep"))); public static final DeferredHolder C4_FINAL = REGISTRY.register("c4_final", () -> SoundEvent.createVariableRangeEvent(Mod.loc("c4_final"))); @@ -433,6 +430,7 @@ public class ModSounds { public static final DeferredHolder PRISM_FIRE_3P = REGISTRY.register("prism_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("prism_fire_3p"))); public static final DeferredHolder PRISM_FIRE_1P_2 = REGISTRY.register("prism_fire_1p_2", () -> SoundEvent.createVariableRangeEvent(Mod.loc("prism_fire_1p_2"))); public static final DeferredHolder PRISM_FIRE_3P_2 = REGISTRY.register("prism_fire_3p_2", () -> SoundEvent.createVariableRangeEvent(Mod.loc("prism_fire_3p_2"))); + public static final DeferredHolder PRISM_ENGINE = REGISTRY.register("prism_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("prism_engine"))); public static final DeferredHolder INSIDIOUS_FIRE_1P = REGISTRY.register("insidious_fire_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("insidious_fire_1p"))); public static final DeferredHolder INSIDIOUS_FIRE_3P = REGISTRY.register("insidious_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("insidious_fire_3p"))); public static final DeferredHolder INSIDIOUS_FAR = REGISTRY.register("insidious_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("insidious_far"))); @@ -442,8 +440,7 @@ public class ModSounds { public static final DeferredHolder HPJ_11_FIRE_3P = REGISTRY.register("hpj_11_fire_3p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_fire_3p"))); public static final DeferredHolder HPJ_11_FAR = REGISTRY.register("hpj_11_far", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_far"))); public static final DeferredHolder HPJ_11_VERYFAR = REGISTRY.register("hpj_11_veryfar", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hpj_11_veryfar"))); - public static final DeferredHolder WIND_LOOP = REGISTRY.register("wind_loop", () -> SoundEvent.createVariableRangeEvent(Mod.loc("wind_loop"))); + public static final DeferredHolder TRACK_MOVE = REGISTRY.register("track_move", () -> SoundEvent.createVariableRangeEvent(Mod.loc("track_move"))); public static final DeferredHolder A_10_ENGINE = REGISTRY.register("a10_engine", () -> SoundEvent.createVariableRangeEvent(Mod.loc("a10_engine"))); - public static final DeferredHolder A_10_ENGINE_1P = REGISTRY.register("a10_engine_1p", () -> SoundEvent.createVariableRangeEvent(Mod.loc("a10_engine_1p"))); } diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index 082e0834f..0eda480cf 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -2474,8 +2474,8 @@ "wheel_chair_engine": { "sounds": [ { - "name": "superbwarfare:wheel_chair/wheel_chair_engine", - "stream": false + "stream": true, + "name": "superbwarfare:wheel_chair/wheel_chair_engine" } ] }, @@ -2518,17 +2518,12 @@ "helicopter_engine": { "sounds": [ { + "attenuation_distance": 160, + "stream": true, "name": "superbwarfare:helicopter/heli_engine" } ] }, - "helicopter_engine_1p": { - "sounds": [ - { - "name": "superbwarfare:helicopter/heli_engine_1p" - } - ] - }, "heli_cannon_fire_1p": { "sounds": [ { @@ -2788,17 +2783,12 @@ "lav_engine": { "sounds": [ { + "attenuation_distance": 64, + "stream": true, "name": "superbwarfare:lav/lav_engine" } ] }, - "lav_engine_1p": { - "sounds": [ - { - "name": "superbwarfare:lav/lav_engine_1p" - } - ] - }, "coax_fire_1p": { "sounds": [ { @@ -2825,17 +2815,12 @@ "bmp_engine": { "sounds": [ { + "attenuation_distance": 64, + "stream": true, "name": "superbwarfare:bmp/bmp_engine" } ] }, - "bmp_engine_1p": { - "sounds": [ - { - "name": "superbwarfare:bmp/bmp_engine_1p" - } - ] - }, "bmp_missile_fire_1p": { "sounds": [ { @@ -2860,14 +2845,6 @@ } ] }, - "bmp_step": { - "sounds": [ - { - "name": "superbwarfare:bmp/bmp_step", - "stream": false - } - ] - }, "wheel_step": { "sounds": [ { @@ -2924,6 +2901,15 @@ } ] }, + "yx_100_engine": { + "sounds": [ + { + "attenuation_distance": 64, + "stream": true, + "name": "superbwarfare:yx100/yx100_engine" + } + ] + }, "turret_turn": { "sounds": [ { @@ -2996,6 +2982,15 @@ } ] }, + "prism_engine": { + "sounds": [ + { + "attenuation_distance": 64, + "stream": true, + "name": "superbwarfare:prism/prism_engine" + } + ] + }, "insidious_fire_1p": { "sounds": [ { @@ -3068,25 +3063,22 @@ } ] }, - "wind_loop": { + "track_move": { "sounds": [ { - "name": "superbwarfare:wind_loop" + "attenuation_distance": 32, + "stream": true, + "name": "superbwarfare:track_move" } ] }, "a10_engine": { "sounds": [ { + "attenuation_distance": 160, + "stream": true, "name": "superbwarfare:a10/a10_engine" } ] - }, - "a10_engine_1p": { - "sounds": [ - { - "name": "superbwarfare:a10/a10_engine_1p" - } - ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/Treads_01_Wave 0 0 0.mp3 b/src/main/resources/assets/superbwarfare/sounds/Treads_01_Wave 0 0 0.mp3 new file mode 100644 index 000000000..17d18be07 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/Treads_01_Wave 0 0 0.mp3 differ diff --git a/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine.ogg index 34c059b51..10aa31b45 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine.ogg and b/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine_1p.ogg deleted file mode 100644 index f31ea63cc..000000000 Binary files a/src/main/resources/assets/superbwarfare/sounds/a10/a10_engine_1p.ogg and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine.ogg index 4a57a4745..275237151 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine.ogg and b/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine_1p.ogg deleted file mode 100644 index a9d72e2f3..000000000 Binary files a/src/main/resources/assets/superbwarfare/sounds/bmp/bmp_engine_1p.ogg and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine.ogg index 2aa953332..64d332fa8 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine.ogg and b/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine_1p.ogg deleted file mode 100644 index 3a0a8eac7..000000000 Binary files a/src/main/resources/assets/superbwarfare/sounds/helicopter/heli_engine_1p.ogg and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg index 5cbc0c66b..616689d30 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg and b/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine_1p.ogg deleted file mode 100644 index 41424def2..000000000 Binary files a/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine_1p.ogg and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/sounds/prism/prism_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/prism/prism_engine.ogg new file mode 100644 index 000000000..ef8b424fe Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/prism/prism_engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/track_move.ogg b/src/main/resources/assets/superbwarfare/sounds/track_move.ogg new file mode 100644 index 000000000..f7390a2e5 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/track_move.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/wind_loop.ogg b/src/main/resources/assets/superbwarfare/sounds/wind_loop.ogg deleted file mode 100644 index b96d5d96c..000000000 Binary files a/src/main/resources/assets/superbwarfare/sounds/wind_loop.ogg and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/sounds/yx100/yx100_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/yx100/yx100_engine.ogg new file mode 100644 index 000000000..3118c7241 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/yx100/yx100_engine.ogg differ