From 9cba24e32a54c6e0520131ee3d937a944008a5b9 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Sat, 3 Feb 2024 00:50:25 -0500 Subject: [PATCH] Fix cycling controls not playing a sound when activated using the keyboard Fixes #2309 --- .../sodium/client/gui/options/control/CyclingControl.java | 6 +++--- .../sodium/client/gui/options/control/TickBoxControl.java | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/CyclingControl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/CyclingControl.java index 7c1ce635d5..b39278e384 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/CyclingControl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/CyclingControl.java @@ -100,8 +100,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { public boolean mouseClicked(double mouseX, double mouseY, int button) { if (this.option.isAvailable() && button == 0 && this.dim.containsCursor(mouseX, mouseY)) { cycleControl(Screen.hasShiftDown()); - this.playClickSound(); - return true; } @@ -120,7 +118,9 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return false; } - public void cycleControl(boolean reverse) { + private void cycleControl(boolean reverse) { + this.playClickSound(); + if (reverse) { this.currentIndex = (this.currentIndex + this.allowedValues.length - 1) % this.allowedValues.length; } else { diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/TickBoxControl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/TickBoxControl.java index a77748105d..378f2789b1 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/TickBoxControl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/TickBoxControl.java @@ -68,8 +68,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { public boolean mouseClicked(double mouseX, double mouseY, int button) { if (this.option.isAvailable() && button == 0 && this.dim.containsCursor(mouseX, mouseY)) { toggleControl(); - this.playClickSound(); - return true; } @@ -82,15 +80,14 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (CommonInputs.selected(keyCode)) { toggleControl(); - this.playClickSound(); - return true; } return false; } - public void toggleControl() { + private void toggleControl() { + this.playClickSound(); this.option.setValue(!this.option.getValue()); } }