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 f36557476..921751347 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -26,6 +26,7 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -138,6 +139,24 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC if (source.is(ModDamageTypes.VEHICLE_STRIKE)) { amount *= 0.7f; } + if (source.is(DamageTypes.PLAYER_ATTACK)) { + amount *= 0.05f; + } + if (source.is(DamageTypes.MOB_ATTACK)) { + amount *= 0.05f; + } + if (source.is(DamageTypes.MOB_ATTACK_NO_AGGRO)) { + amount *= 0.05f; + } + if (source.is(DamageTypes.MOB_PROJECTILE)) { + amount *= 0.05f; + } + if (source.is(DamageTypes.ARROW)) { + amount *= 0.05f; + } + if (source.is(DamageTypes.TRIDENT)) { + amount *= 0.05f; + } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); this.hurt(0.5f * Math.max(amount - 15, 0)); @@ -365,10 +384,6 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC this.extraEnergy(VehicleConfig.SPEEDBOAT_ENERGY_COST.get()); } - if (level().isClientSide) { - level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.forwardInputDown || this.backInputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1f), false); - } - this.entityData.set(POWER, this.entityData.get(POWER) * 0.97f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * (float)Math.max(0.7f - 0.1f * this.getDeltaMovement().horizontalDistance(), 0.3)); @@ -451,7 +466,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC @Override public SoundEvent getEngineSound() { - return ModSounds.BOAT_ENGINE.get(); + return ModSounds.LAV_ENGINE.get(); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java index 9f2a75e6d..fa6ee1484 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientSoundHandler.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.event; import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity; +import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity; import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.tools.SeekTool; @@ -8,6 +9,7 @@ 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.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; @@ -19,6 +21,7 @@ import org.joml.Math; import java.util.List; import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.PROPELLER_ROT; +import static com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity.POWER; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientSoundHandler { @@ -49,7 +52,15 @@ public class ClientSoundHandler { 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.0f), false); + 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(), 2 * (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); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 7f7db48a7..6aeddb245 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -400,5 +400,7 @@ public class ModSounds { public static final RegistryObject LAV_CANNON_FIRE_3P = REGISTRY.register("lav_cannon_fire_3p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_fire_3p"))); public static final RegistryObject LAV_CANNON_FAR = REGISTRY.register("lav_cannon_far", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_far"))); public static final RegistryObject LAV_CANNON_VERYFAR = REGISTRY.register("lav_cannon_veryfar", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_veryfar"))); + public static final RegistryObject LAV_ENGINE = REGISTRY.register("lav_engine", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_engine"))); + public static final RegistryObject LAV_ENGINE_1P = REGISTRY.register("lav_engine_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lav_engine_1p"))); } diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index 7578df4fc..692afd5dd 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -2736,5 +2736,19 @@ "stream": false } ] + }, + "lav_engine": { + "sounds": [ + { + "name": "superbwarfare:lav/lav_engine" + } + ] + }, + "lav_engine_1p": { + "sounds": [ + { + "name": "superbwarfare:lav/lav_engine_1p" + } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg b/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine.ogg new file mode 100644 index 000000000..5cbc0c66b Binary files /dev/null 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 new file mode 100644 index 000000000..41424def2 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/lav/lav_engine_1p.ogg differ