Skip to content

Commit d0602b8

Browse files
committed
Scribbly page sounds
1 parent cb0a0dd commit d0602b8

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

common/src/main/java/com/evandev/fieldguide/client/gui/screens/FieldGuideEntryScreen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import net.minecraft.network.chat.MutableComponent;
3434
import net.minecraft.resources.ResourceLocation;
3535
import net.minecraft.sounds.SoundEvent;
36+
import net.minecraft.sounds.SoundEvents;
3637
import net.minecraft.world.entity.*;
3738
import net.minecraft.world.item.Item;
3839
import net.minecraft.world.item.ItemStack;
@@ -185,7 +186,10 @@ protected void init() {
185186
this.onClose();
186187
}
187188
}
188-
}).setPlaySound(canCopy)).setTooltip(createCopyTooltip(canCopy));
189+
})
190+
.setPlaySound(canCopy)
191+
.setCustomSound(SoundEvents.VILLAGER_WORK_CARTOGRAPHER))
192+
.setTooltip(createCopyTooltip(canCopy));
189193
}
190194

191195
if (this.entityVariants.size() > 1 && this.renderedEntity instanceof LivingEntity living) {

common/src/main/java/com/evandev/fieldguide/client/gui/widget/PageTurnButton.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
import net.minecraft.client.gui.components.ImageButton;
55
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
66
import net.minecraft.client.sounds.SoundManager;
7-
import net.minecraft.network.chat.CommonComponents;
87
import net.minecraft.resources.ResourceLocation;
8+
import net.minecraft.sounds.SoundEvent;
99
import net.minecraft.sounds.SoundEvents;
10+
import org.jetbrains.annotations.NotNull;
1011

1112
public 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

Comments
 (0)