Fixed music continuing to play for server bards even after logging out

This commit is contained in:
Luis C.M. committed 2025-03-05 22:57:24 -06:00
1 parent 6e1b2f957f
commit b64481dec1
3 files changed
+8 -5

No files matched your search

@@ -1,6 +1,7 @@
package noppes.npcs.client;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.select.GuiTextureSelection;
@@ -61,6 +62,9 @@ public class ClientCacheHandler {
// Clear Texture Caches
GuiSoundSelection.cachedDomains.clear();
GuiTextureSelection.cachedTextures.clear();
// Clear music/bard sounds
MusicController.Instance.stopAllSounds();
}
public static void clearSkinCache() {
@@ -68,10 +68,8 @@ public class ClientTickHandler{
otherContainer = true;
CustomNpcs.ticks++;
RenderNPCInterface.LastTextureTick++;
if(prevWorld != mc.theWorld){
prevWorld = mc.theWorld;
MusicController.Instance.stopAllSounds();
} else if (MusicController.Instance.isPlaying() && MusicController.Instance.getEntity() != null) {
if (MusicController.Instance.isPlaying() && MusicController.Instance.getEntity() != null) {
Entity entity = MusicController.Instance.getEntity();
if (MusicController.Instance.getOffRange() > 0 &&
(Minecraft.getMinecraft().thePlayer == null ||
@@ -80,6 +78,7 @@ public class ClientTickHandler{
MusicController.Instance.stopMusic();
}
}
MusicController.Instance.onUpdate();
ScriptSoundController.Instance.onUpdate();
if(Minecraft.getMinecraft().thePlayer!=null && (prevWidth!=mc.displayWidth || prevHeight!=mc.displayHeight)){
@@ -61,7 +61,7 @@ public class MusicController {
soundHandler.stopSounds();
} catch (Exception ignored) {}
}
if (this.isPlaying()) {
if (this.playingSound != null) {
this.playingSound.stopSound();
this.playingSound = null;
}