Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cycling controls not playing a sound when activated using the keyboard #2313

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.input.KeyCodes;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.apache.commons.lang3.Validate;

Expand Down Expand Up @@ -101,8 +100,6 @@ public void render(DrawContext drawContext, 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;
}

Expand All @@ -121,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import me.jellysquid.mods.sodium.client.util.Dim2i;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.input.KeyCodes;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.math.Rect2i;

public class TickBoxControl implements Control<Boolean> {
Expand Down Expand Up @@ -69,8 +68,6 @@ public void render(DrawContext drawContext, 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;
}

Expand All @@ -83,15 +80,14 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {

if (KeyCodes.isToggle(keyCode)) {
toggleControl();
this.playClickSound();

return true;
}

return false;
}

public void toggleControl() {
private void toggleControl() {
this.playClickSound();
this.option.setValue(!this.option.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.client.gui.navigation.GuiNavigation;
import net.minecraft.client.gui.navigation.GuiNavigationPath;
import net.minecraft.client.input.KeyCodes;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Loading