diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-24 11:39:26 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-24 11:39:26 +0200 |
commit | 169c9dbd29c6015fda3c482feec0bdee78e00fef (patch) | |
tree | 7a13c82ecdbcfd20ba94ecd615f43d009e89217c /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 531506dcf7b61e2dea50e14bfe32e9547f7997be (diff) | |
download | skyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.tar.gz skyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.tar.bz2 skyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.zip |
fire pillar sound and entities
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt new file mode 100644 index 000000000..1fb107375 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -0,0 +1,34 @@ +package at.hannibal2.skyhanni.utils + +import net.minecraft.client.Minecraft +import net.minecraft.client.audio.ISound +import net.minecraft.client.audio.PositionedSound +import net.minecraft.client.audio.SoundCategory +import net.minecraft.util.ResourceLocation + +object SoundUtils { + fun ISound.playSound() { + val gameSettings = Minecraft.getMinecraft().gameSettings + val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS) + gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f) + try { + Minecraft.getMinecraft().soundHandler.playSound(this) + } catch (e: Exception) { + e.printStackTrace() + } + gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel) + } + + fun createSound(name: String, pitch: Float): ISound { + val sound: ISound = object : PositionedSound(ResourceLocation(name)) { + init { + volume = 50f + repeat = false + repeatDelay = 0 + attenuationType = ISound.AttenuationType.NONE + this.pitch = pitch + } + } + return sound + } +}
\ No newline at end of file |