Skip to content

Commit

Permalink
Sound: Fix setVolume and setPitch doing nothing (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattco98 committed Jan 7, 2024
1 parent cfa1614 commit 76227d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/kotlin/com/chattriggers/ctjs/api/client/Sound.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 76227d6

Please sign in to comment.