From 0ad3f83eb5a7f49cb660d7ab83709e3aa34ff792 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:32:04 +0100 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 | 8 +++----- 2 files changed, 6 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 62946e3134..939d851c1a 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 @@ -69,8 +69,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { public boolean mouseClicked(double mouseX, double mouseY, int button) { if (this.option.isEnabled() && button == 0 && this.isMouseOver(mouseX, mouseY)) { cycleControl(Screen.hasShiftDown()); - this.playClickSound(); - return true; } @@ -89,7 +87,9 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return false; } - public void cycleControl(boolean reverse) { + private void cycleControl(boolean reverse) { + this.playClickSound(); + var currentValue = this.option.getValidatedValue(); int startIndex = 0; for (; startIndex < this.baseValues.length; startIndex++) { 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 caaf036ea2..64e557b42c 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 @@ -80,8 +80,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { public boolean mouseClicked(double mouseX, double mouseY, int button) { if (this.option.isEnabled() && button == 0 && this.isMouseOver(mouseX, mouseY)) { toggleControl(); - this.playClickSound(); - return true; } @@ -94,15 +92,15 @@ 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.modifyValue(!this.option.getValidatedValue()); } }