2222import net .minecraft .client .resources .sounds .SoundInstance ;
2323import net .minecraft .resources .ResourceLocation ;
2424import net .minecraft .sounds .SoundSource ;
25- import org .jetbrains .annotations .Nullable ;
2625
2726import static dev .terminalmc .clientsort .config .Config .options ;
2827
2928public class SoundUtil {
3029 private static long time = Long .MIN_VALUE ;
3130 private static float pitch = 1.0F ;
3231 private static float increment = 0.01F ;
33- private static @ Nullable SoundInstance sound ;
3432
3533 public static void reset (int size ) {
3634 increment = (options ().soundMaxPitch - options ().soundMinPitch ) / size ;
@@ -53,14 +51,10 @@ public static void play() {
5351 time = now + options ().soundRate ;
5452 ResourceLocation location = options ().sortSoundLoc ;
5553 if (location != null ) {
56- if (sound != null ) {
57- Minecraft .getInstance ().getSoundManager ().stop (sound );
58- }
59- sound = new SimpleSoundInstance (
54+ Minecraft .getInstance ().getSoundManager ().play (new SimpleSoundInstance (
6055 location , SoundSource .MASTER , options ().soundVolume , soundPitch ,
6156 SoundInstance .createUnseededRandom (), false , 0 ,
62- SoundInstance .Attenuation .NONE , 0 , 0 , 0 , true );
63- Minecraft .getInstance ().getSoundManager ().play (sound );
57+ SoundInstance .Attenuation .NONE , 0 , 0 , 0 , true ));
6458 }
6559 }
6660 }
0 commit comments