44import net .minecraft .client .gui .components .ImageButton ;
55import net .minecraft .client .resources .sounds .SimpleSoundInstance ;
66import net .minecraft .client .sounds .SoundManager ;
7- import net .minecraft .network .chat .CommonComponents ;
87import net .minecraft .resources .ResourceLocation ;
8+ import net .minecraft .sounds .SoundEvent ;
99import net .minecraft .sounds .SoundEvents ;
10+ import org .jetbrains .annotations .NotNull ;
1011
1112public class PageTurnButton extends ImageButton {
1213 private boolean playSound = true ;
14+ private SoundEvent customSound = SoundEvents .BOOK_PAGE_TURN ;
1315
1416 public PageTurnButton (int x , int y , int width , int height , int xTexStart , int yTexStart , int yDiffTex , ResourceLocation resourceLocation , Button .OnPress onPress ) {
1517 super (x , y , width , height , xTexStart , yTexStart , yDiffTex , resourceLocation , onPress );
1618 }
1719
18- public PageTurnButton (int x , int y , int width , int height , int xTexStart , int yTexStart , int yDiffTex , ResourceLocation resourceLocation , int textureWidth , int textureHeight , Button .OnPress onPress ) {
19- super (x , y , width , height , xTexStart , yTexStart , yDiffTex , resourceLocation , textureWidth , textureHeight , onPress , CommonComponents .EMPTY );
20+ public PageTurnButton setCustomSound (SoundEvent sound ) {
21+ this .customSound = sound ;
22+ return this ;
2023 }
2124
2225 public PageTurnButton setPlaySound (boolean playSound ) {
@@ -25,9 +28,9 @@ public PageTurnButton setPlaySound(boolean playSound) {
2528 }
2629
2730 @ Override
28- public void playDownSound (SoundManager handler ) {
31+ public void playDownSound (@ NotNull SoundManager handler ) {
2932 if (playSound ) {
30- handler .play (SimpleSoundInstance .forUI (SoundEvents . BOOK_PAGE_TURN , 1.0F ));
33+ handler .play (SimpleSoundInstance .forUI (this . customSound , 1.0F ));
3134 }
3235 }
33- }
36+ }
0 commit comments