diff options
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 |