From 24e380aa495530e62dd04d98aa52915d904eb323 Mon Sep 17 00:00:00 2001 From: kyrptonaught Date: Sun, 7 Jul 2024 00:38:30 -0400 Subject: [PATCH] Fix music not always playing --- gradle.properties | 2 +- .../switchableresourcepacks/status/MusicStatus.java | 9 +++++++++ .../switchableresourcepacks/status/PlayerStatus.java | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 01f6c37..924fdcc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.parallel=true # Fabric Properties minecraft_version=1.21 -yarn_mappings=1.21+build.2 +yarn_mappings=1.21+build.7 loader_version=0.15.11 # Fabric API diff --git a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/MusicStatus.java b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/MusicStatus.java index 1989da3..29acac4 100644 --- a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/MusicStatus.java +++ b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/MusicStatus.java @@ -29,6 +29,8 @@ public void setMusic(MusicPack pack) { if (pack == null) { this.masterPack = null; this.playingPack = null; + this.currentSong = null; + this.endTime = 0; return; } @@ -37,6 +39,12 @@ public void setMusic(MusicPack pack) { this.playingPack.songs = new LinkedHashMap<>(); this.playingPack.play_order = pack.play_order; this.playingPack.delay = pack.delay; + this.currentSong = null; + this.endTime = 0; + } + + public void play() { + tickMusic = true; } public boolean isSongFinished(long currentTime) { @@ -86,6 +94,7 @@ private void playSong(ServerPlayerEntity player, Identifier songID) { Vec3d vec3d = player.getPos(); player.networkHandler.sendPacket(new PlaySoundS2CPacket(registryEntry, SoundCategory.MUSIC, vec3d.getX(), vec3d.getY(), vec3d.getZ(), 1, 1, player.getRandom().nextLong())); + System.out.println("Playing " + songID + " for " + player.getName().getString()); } private void stopSong(ServerPlayerEntity player) { diff --git a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/PlayerStatus.java b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/PlayerStatus.java index 76f6108..863ecc3 100644 --- a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/PlayerStatus.java +++ b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/status/PlayerStatus.java @@ -18,7 +18,7 @@ public void tick(ServerPlayerEntity player, long currentTime) { } public void startMusic() { - musicStatus.tickMusic = true; + musicStatus.play(); } public void skipSong(ServerPlayerEntity player) {