From ecbb0f68bbbd0dcea6c1a75855010d633625cc62 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Tue, 12 Jul 2022 19:13:52 +0200 Subject: Added sound for 30s fishing timer (#184) * Added sound for 30s fishing timer * move code and play sound only once * remove seconds check Co-authored-by: Lulonaut --- .../notenoughupdates/miscfeatures/FishingHelper.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 26e25a11..13a078a2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -92,6 +92,7 @@ public class FishingHelper { private int pingDelayTicks = 0; private final List pingDelayList = new ArrayList<>(); private int buildupSoundDelay = 0; + private boolean playedSound = false; private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation( "notenoughupdates:fishing_warning_exclam.png"); @@ -146,10 +147,26 @@ public class FishingHelper { int ticksExisted = hook.ticksExisted; float seconds = ticksExisted / 20F; int color; - if (seconds > 30) { + if (seconds >= 30) { color = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.fishing.fishingTimerColor30SecPlus); + if (NotEnoughUpdates.INSTANCE.config.fishing.fishingSound30Sec && !playedSound) { + ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{ + volume = 50; + pitch = 2f; + repeat = false; + repeatDelay = 0; + attenuationType = ISound.AttenuationType.NONE; + }}; + + float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel); + playedSound = true; + } } else { color = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.fishing.fishingTimerColor); + playedSound = false; } Utils.drawStringCentered( -- cgit