File tree Expand file tree Collapse file tree 6 files changed +42
-15
lines changed
gui/impl/clickgui/buttons/setting
resources/assets/lambda/sound Expand file tree Collapse file tree 6 files changed +42
-15
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ object Loader {
2222 LambdaFont .Loader ,
2323 GuiConfigurable ,
2424 FriendManager ,
25+ SoundManager ,
2526 )
2627
2728 fun initialize () {
Original file line number Diff line number Diff line change 1+ package com.lambda.core
2+
3+ import com.lambda.Lambda
4+ import com.lambda.context.SafeContext
5+ import net.minecraft.client.sound.PositionedSoundInstance
6+ import net.minecraft.registry.Registries
7+ import net.minecraft.registry.Registry
8+ import net.minecraft.sound.SoundEvent
9+ import net.minecraft.util.Identifier
10+
11+ object SoundManager : Loadable {
12+
13+ override fun load (): String {
14+ LambdaSound .entries.forEach {
15+ Registry .register(Registries .SOUND_EVENT , it.id, it.event)
16+ }
17+
18+ return " Loaded ${LambdaSound .entries.size} sounds"
19+ }
20+
21+ enum class LambdaSound (val id : Identifier ) {
22+ MODULE_TOGGLE (" module_toggle" .toIdentifier());
23+
24+ val event: SoundEvent = SoundEvent .of(id)
25+ }
26+
27+ fun SafeContext.playSound (event : SoundEvent , pitch : Float = 1.0f) {
28+ mc.soundManager.play(
29+ PositionedSoundInstance .master(event, pitch)
30+ )
31+ }
32+
33+ private fun String.toIdentifier () = Identifier (" ${Lambda .MOD_ID } :${this } " )
34+ }
Original file line number Diff line number Diff line change 11package com.lambda.gui.impl.clickgui.buttons.setting
22
33import com.lambda.config.settings.comparable.BooleanSetting
4+ import com.lambda.core.SoundManager
5+ import com.lambda.core.SoundManager.playSound
46import com.lambda.graphics.animation.Animation.Companion.exp
57import com.lambda.gui.api.GuiEvent
68import com.lambda.gui.api.component.core.list.ChildLayer
79import com.lambda.gui.impl.clickgui.buttons.SettingButton
810import com.lambda.module.modules.client.GuiSettings
11+ import com.lambda.threading.runSafe
912import com.lambda.util.Mouse
1013import com.lambda.util.math.ColorUtils.setAlpha
1114import com.lambda.util.math.MathUtils.lerp
@@ -47,5 +50,8 @@ class BooleanButton(
4750
4851 override fun performClickAction (e : GuiEvent .MouseClick ) {
4952 if (e.button == Mouse .Button .Left ) value = ! value
53+ runSafe {
54+ playSound(SoundManager .LambdaSound .MODULE_TOGGLE .event)
55+ }
5056 }
5157}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.google.gson.*
44import com.lambda.brigadier.CommandResult
55import com.lambda.config.RotationSettings
66import com.lambda.context.SafeContext
7+ import com.lambda.core.SoundManager.playSound
78import com.lambda.core.TimerManager
89import com.lambda.event.EventFlow.lambdaScope
910import com.lambda.event.events.KeyPressEvent
@@ -25,9 +26,7 @@ import com.lambda.util.FolderRegister.locationBoundDirectory
2526import com.lambda.util.Formatting.asString
2627import com.lambda.util.Formatting.getTime
2728import com.lambda.util.KeyCode
28- import com.lambda.util.SoundUtils.playSound
2929import com.lambda.util.StringUtils.sanitizeForFilename
30- import com.lambda.util.math.MathUtils.roundToStep
3130import com.lambda.util.primitives.extension.rotation
3231import com.lambda.util.text.*
3332import kotlinx.coroutines.Dispatchers
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments