diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index 82b3da95b..b9ba3fcfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.item.weapon +import net.minecraft.sounds.SoundSource import net.minecraft.util.Mth import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player @@ -9,6 +10,7 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.entity.PlasmaProjectile import ru.dbotthepony.mc.otm.position +import ru.dbotthepony.mc.otm.registry.MSoundEvents import java.util.* import kotlin.math.PI import kotlin.math.cos @@ -145,6 +147,15 @@ class PlasmaRifleItem : PlasmaWeaponItem(WeaponDataTable::class dt.doFireAnim(deviation = rotFireAnimDeviation) } + player.level.playSound( + player, + player, + MSoundEvents.RIFLE_SHOT, + SoundSource.NEUTRAL, + 1f, + 1f + ) + return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index bfc8326c6..0961cf185 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -104,6 +104,7 @@ object MRegistry { MItems.register() AndroidFeatures.register() AndroidResearch.register() + MSoundEvents.register() } private fun register(event: NewRegistryEvent) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt new file mode 100644 index 000000000..58f759899 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.resources.ResourceLocation +import net.minecraft.sounds.SoundEvent +import net.minecraft.world.entity.EntityType +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext +import net.minecraftforge.registries.DeferredRegister +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.OverdriveThatMatters + +object MSoundEvents { + private val registry: DeferredRegister = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, OverdriveThatMatters.MOD_ID) + + val RIFLE_SHOT by registry.register("item.rifle_shot") { SoundEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, "item.rifle_shot")) } + + internal fun register() { + registry.register(FMLJavaModLoadingContext.get().modEventBus) + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json index 6a577c848..8dbf13b49 100644 --- a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json +++ b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json @@ -1,4 +1,5 @@ { + "otm.sound.rifle_shoot": "Plasma rifle fire", "itemGroup.otm": "Overdrive That Matters", "otm.pill.warning": "WARNING: This will INSTANTLY decommission you upon ingestion!", diff --git a/src/main/resources/assets/overdrive_that_matters/sounds.json b/src/main/resources/assets/overdrive_that_matters/sounds.json new file mode 100644 index 000000000..74cf34289 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/sounds.json @@ -0,0 +1,12 @@ +{ + "item.rifle_shot": { + "subtitle": "otm.sound.rifle_shoot", + "sounds": [ + { + "name": "overdrive_that_matters:item/rifle_shot", + "volume": 1.0, + "weight": 1 + } + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/sounds/item/rifle_shot.ogg b/src/main/resources/assets/overdrive_that_matters/sounds/item/rifle_shot.ogg new file mode 100644 index 000000000..82f78ecdf Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/sounds/item/rifle_shot.ogg differ