Read sound event objects properly in jukebox song

This commit is contained in:
Eclipse 2024-06-16 23:14:32 +00:00
parent 1efb633723
commit 036e0270f0
No known key found for this signature in database
GPG key ID: 441A0B7FDD01D03A

View file

@ -33,7 +33,13 @@ public record JukeboxSong(String soundEvent, String description) {
public static JukeboxSong read(RegistryEntry entry) {
NbtMap data = entry.getData();
String soundEvent = data.getString("sound_event");
Object soundEventObject = data.get("sound_event");
String soundEvent = "";
if (soundEventObject instanceof NbtMap map) {
soundEvent = map.getString("sound_id");
} else if (soundEventObject instanceof String string){
soundEvent = string;
}
String description = MessageTranslator.deserializeDescription(data);
return new JukeboxSong(soundEvent, description);
}