From 76227d6b1e3675c614cd5aa9075661ade1ca3e06 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 7 Jan 2024 09:31:14 -0700 Subject: [PATCH] Sound: Fix setVolume and setPitch doing nothing (again) --- .../kotlin/com/chattriggers/ctjs/api/client/Sound.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/chattriggers/ctjs/api/client/Sound.kt b/src/main/kotlin/com/chattriggers/ctjs/api/client/Sound.kt index eede1235..2d6fcd61 100644 --- a/src/main/kotlin/com/chattriggers/ctjs/api/client/Sound.kt +++ b/src/main/kotlin/com/chattriggers/ctjs/api/client/Sound.kt @@ -106,7 +106,7 @@ class Sound(private val config: NativeObject) { } val initialData = soundData - soundData = BootstrappedSoundData(sound, soundImpl, initialData.volume, initialData.pitch) + soundData = BootstrappedSoundData(sound, soundImpl) // Apply all initial values as the user may have changed them soundData.loop = initialData.loop @@ -117,6 +117,8 @@ class Sound(private val config: NativeObject) { soundData.attenuation = initialData.attenuation soundData.category = initialData.category soundData.attenuationType = initialData.attenuationType + soundData.volume = initialData.volume + soundData.pitch = initialData.pitch } fun destroy() { @@ -345,12 +347,13 @@ class Sound(private val config: NativeObject) { private class BootstrappedSoundData( private val sound: MCSound, private val impl: SoundImpl, - override var volume: Float, - override var pitch: Float, ) : SoundData { private val mixedSound: SoundAccessor = sound.asMixin() private val mixedImpl: AbstractSoundInstanceAccessor = impl.asMixin() + override var volume by impl::volume + override var pitch by impl::pitch + override var loop: Boolean get() = impl.isRepeatable set(value) {