diff options
author | nea <nea@nea.moe> | 2023-07-18 02:52:25 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-07-18 02:53:37 +0200 |
commit | 25fb78ace82779fa6e5b45fc20fa428570c63a59 (patch) | |
tree | 957b67b0d18e8b33bb4c1f6222e5ffb41ccf0e91 /src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt | |
parent | d68c8bb34fe41d47777c4771364d2b94b4fdbdf1 (diff) | |
download | DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.tar.gz DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.tar.bz2 DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.zip |
DUDUDUDUDUDUDUDUDUDUDUDUDUDU
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt b/src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt new file mode 100644 index 0000000..7d623f6 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/SoundUtil.kt @@ -0,0 +1,37 @@ +package com.dulkirfabric.util + +import net.minecraft.client.MinecraftClient +import net.minecraft.client.sound.PositionedSoundInstance +import net.minecraft.client.sound.SoundInstance +import net.minecraft.sound.SoundCategory +import net.minecraft.sound.SoundEvent +import net.minecraft.util.Identifier +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.random.LocalRandom + +object SoundUtil { + val iphone = SoundEvent.of(Identifier("dulkirmod:iphone")) + + + fun stop(sounds: List<SoundInstance>) { + val m = MinecraftClient.getInstance().soundManager + sounds.forEach(m::stop) + } + + fun playSoundAtPlayer(event: SoundEvent): PositionedSoundInstance { + val instance = PositionedSoundInstance( + event, + SoundCategory.MASTER, + 1F, + 1F, + LocalRandom(0L), + MinecraftClient.getInstance().player?.blockPos ?: BlockPos(0, 0, 0) + ) + MinecraftClient.getInstance().soundManager.play(instance) + return instance + } + + fun playIPhoneAlarm(): PositionedSoundInstance { + return playSoundAtPlayer(iphone) + } +}
\ No newline at end of file |