From 8ef48fd27ba046cace0944d6da3c2a7dfb8115c9 Mon Sep 17 00:00:00 2001 From: bconlon Date: Wed, 3 Jun 2020 17:28:21 -0700 Subject: [PATCH] Fixed issue with records not properly cancelling music. --- .../aether/client/audio/AetherMusicHandler.java | 13 ++++++++++--- .../client/audio/music/AetherMusicTicker.java | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/legacy/aether/client/audio/AetherMusicHandler.java b/src/main/java/com/legacy/aether/client/audio/AetherMusicHandler.java index f693944..21ef0d3 100644 --- a/src/main/java/com/legacy/aether/client/audio/AetherMusicHandler.java +++ b/src/main/java/com/legacy/aether/client/audio/AetherMusicHandler.java @@ -31,10 +31,17 @@ public class AetherMusicHandler { if (phase == TickEvent.Phase.END) { if (type.equals(TickEvent.Type.CLIENT)) { if (!this.mc.isGamePaused()) { - this.musicTicker.update(); + if (!musicTicker.playingRecord()) { + this.musicTicker.update(); + } } } } + + if (!(mc.getSoundHandler().isSoundPlaying(musicTicker.getRecord()))) + { + musicTicker.trackRecord(null); + } } @SubscribeEvent @@ -56,9 +63,9 @@ public class AetherMusicHandler { } } } else if (category == SoundCategory.RECORDS && !(event.name.contains("note"))) { - this.musicTicker.stopMusic(); + this.musicTicker.trackRecord(event.sound); this.mc.getSoundHandler().stopSounds(); - + return; } } diff --git a/src/main/java/com/legacy/aether/client/audio/music/AetherMusicTicker.java b/src/main/java/com/legacy/aether/client/audio/music/AetherMusicTicker.java index 0a470eb..d48f3d5 100644 --- a/src/main/java/com/legacy/aether/client/audio/music/AetherMusicTicker.java +++ b/src/main/java/com/legacy/aether/client/audio/music/AetherMusicTicker.java @@ -21,7 +21,7 @@ public class AetherMusicTicker implements IUpdatePlayerListBox { private final Random rand = new Random(); private final Minecraft mc; - private ISound currentMusic; + private ISound currentMusic, currentRecord; private int timeUntilNextMusic = 100; public AetherMusicTicker(Minecraft mcIn) { @@ -64,6 +64,16 @@ public class AetherMusicTicker implements IUpdatePlayerListBox { return this.currentMusic != null; } + public boolean playingRecord() + { + return this.currentRecord != null; + } + + public ISound getRecord() + { + return this.currentRecord; + } + public AetherMusicTicker.TrackType getRandomTrack() { int num = this.rand.nextInt(4); @@ -76,6 +86,11 @@ public class AetherMusicTicker implements IUpdatePlayerListBox { this.timeUntilNextMusic = Integer.MAX_VALUE; } + public void trackRecord(ISound record) + { + this.currentRecord = record; + } + public void stopMusic() { if (this.currentMusic != null) { this.mc.getSoundHandler().stopSound(this.currentMusic);