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 ++++++++++++++++++- .../options/seperateSections/Fishing.java | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/main/java/io') 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( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java index e02413f7..513474ca 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java @@ -264,4 +264,13 @@ public class Fishing { @ConfigAccordionId(id = 6) public String fishingTimerColor30SecPlus = "0:255:0:0:0"; + @Expose + @ConfigOption( + name = "Fishing timer ping (30s)", + desc = "Play a sound after 30 seconds passed" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 6) + public boolean fishingSound30Sec = true; + } -- cgit