fix: more fixes to song stuff

This commit is contained in:
Chayapak Supasakul 2025-03-04 20:26:46 +07:00
parent 1034518f5f
commit b3f5e4f633
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
2 changed files with 8 additions and 6 deletions

View file

@ -12,5 +12,6 @@ public class SoundSystemMixin {
@Inject(method = "getAdjustedPitch", at = @At("HEAD"), cancellable = true) @Inject(method = "getAdjustedPitch", at = @At("HEAD"), cancellable = true)
private void getAdjustedPitch (SoundInstance sound, CallbackInfoReturnable<Float> cir) { private void getAdjustedPitch (SoundInstance sound, CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(sound.getPitch()); cir.setReturnValue(sound.getPitch());
cir.cancel();
} }
} }

View file

@ -64,11 +64,12 @@ public class SongPlayer {
} }
try { try {
loaderThread = new SongLoaderThread(location); final SongLoaderThread _loaderThread = new SongLoaderThread(location);
player.sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN)); player.sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
loaderThread.start(); _loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) { } catch (SongLoaderException e) {
player.sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED)); player.sendMessage(Component.translatable("Failed to load song: %s", Component.text(e.message.getString())).color(NamedTextColor.RED));
loaderThread = null; loaderThread = null;
} }
} }
@ -89,7 +90,7 @@ public class SongPlayer {
_loaderThread.start(); _loaderThread.start();
loaderThread = _loaderThread; loaderThread = _loaderThread;
} catch (SongLoaderException e) { } catch (SongLoaderException e) {
player.sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED)); player.sendMessage(Component.translatable("Failed to load song: %s", Component.text(e.message.getString())).color(NamedTextColor.RED));
loaderThread = null; loaderThread = null;
} }
} }
@ -109,7 +110,7 @@ public class SongPlayer {
if (loaderThread != null && !loaderThread.isAlive() && client.player != null) { if (loaderThread != null && !loaderThread.isAlive() && client.player != null) {
if (loaderThread.exception != null) { if (loaderThread.exception != null) {
client.player.sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message.getString()).color(NamedTextColor.RED)); client.player.sendMessage(Component.translatable("Failed to load song: %s", Component.text(loaderThread.exception.message.getString())).color(NamedTextColor.RED));
} else { } else {
songQueue.add(loaderThread.song); songQueue.add(loaderThread.song);
client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN)); client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));