mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 21:06:16 +00:00
fix: more SongPlayer fixes
This commit is contained in:
parent
7675aae619
commit
d579f8bff8
1 changed files with 6 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -50,6 +51,7 @@ public class SongPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Less duplicate code
|
// TODO: Less duplicate code
|
||||||
|
// TODO: Reduce the mess
|
||||||
|
|
||||||
public void loadSong (final Path location) {
|
public void loadSong (final Path location) {
|
||||||
final ClientPlayerEntity player = client.player;
|
final ClientPlayerEntity player = client.player;
|
||||||
|
|
@ -108,10 +110,12 @@ 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.execute(() -> client.player.sendMessage(Component.translatable("Failed to load song: %s", Component.text(loaderThread.exception.message.getString())).color(NamedTextColor.RED)));
|
final Text exceptionMessage = loaderThread.exception.message;
|
||||||
|
client.execute(() -> client.player.sendMessage(Component.translatable("Failed to load song: %s", Component.text(exceptionMessage.getString())).color(NamedTextColor.RED)));
|
||||||
} else {
|
} else {
|
||||||
songQueue.add(loaderThread.song);
|
songQueue.add(loaderThread.song);
|
||||||
client.execute(() -> client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN)));
|
final Component name = loaderThread.song.name;
|
||||||
|
client.execute(() -> client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN)));
|
||||||
}
|
}
|
||||||
loaderThread = null;
|
loaderThread = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue