4
4
import com .mojang .serialization .Codec ;
5
5
import com .mojang .serialization .codecs .RecordCodecBuilder ;
6
6
import net .minecraft .client .sound .MusicType ;
7
- import net .minecraft .registry .Registries ;
7
+ import net .minecraft .registry .entry . RegistryEntry ;
8
8
import net .minecraft .sound .MusicSound ;
9
9
import net .minecraft .sound .SoundEvent ;
10
- import net .minecraft .sound .SoundEvents ;
11
10
import net .minecraft .util .Identifier ;
12
11
13
12
import java .util .List ;
@@ -19,16 +18,16 @@ public class Panorama {
19
18
public static final Codec <MusicSound > OPTIONAL_MUSIC_SOUND_CODEC = RecordCodecBuilder .create (
20
19
(instance ) ->
21
20
instance .group (
22
- SoundEvent .CODEC .optionalFieldOf ("sound" )
23
- .forGetter ((sound ) -> Optional . of ( sound .getSound ().value () )),
21
+ Identifier .CODEC .fieldOf ("sound" )
22
+ .forGetter ((sound ) -> sound .getSound ().getKey (). orElseThrow (). getValue ( )),
24
23
Codec .INT .optionalFieldOf ("min_delay" )
25
24
.forGetter ((sound ) -> Optional .of (sound .getMinDelay ())),
26
25
Codec .INT .optionalFieldOf ("max_delay" )
27
26
.forGetter ((sound ) -> Optional .of (sound .getMaxDelay ())),
28
27
Codec .BOOL .optionalFieldOf ("replace_current_music" )
29
28
.forGetter ((sound ) -> Optional .of (sound .shouldReplaceCurrentMusic ()))
30
29
)
31
- .apply (instance , (sound , min , max , replace )-> new MusicSound (sound . map ( Registries . SOUND_EVENT :: getEntry ). orElse ( SoundEvents . MUSIC_MENU ), min .orElse (20 ), max .orElse (600 ), replace .orElse (true ))));
30
+ .apply (instance , (sound , min , max , replace ) -> new MusicSound (RegistryEntry . of ( SoundEvent . of ( sound ) ), min .orElse (20 ), max .orElse (600 ), replace .orElse (true ))));
32
31
33
32
public static final Codec <Panorama > CODEC = RecordCodecBuilder .create (
34
33
(instance ) ->
0 commit comments