Skip to content

Commit

Permalink
Re-init pitch on open options and key release
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Aug 7, 2023
1 parent 540b9be commit 28b4dd3
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,38 +251,33 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) {
private boolean pitchChanged;
protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) {
if (!pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) {
pitchInstrumentUp(true);
setPitch(getPitch() + 1);
pitchChanged = true;
return true;
}
if (!pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) {
pitchInstrumentDown(true);
setPitch(getPitch() - 1);
pitchChanged = true;
return true;
}

return false;
}
protected boolean checkPitchInstrumentDown(int pKeyCode, int pScanCode) {
if (pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) {
pitchInstrumentDown(false);
initPitch(this::setPitch);
pitchChanged = false;
return true;
}
if (pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) {
pitchInstrumentUp(false);
initPitch(this::setPitch);
pitchChanged = false;
return true;
}

return false;
}

private void pitchInstrumentUp(final boolean pressed) {
setPitch(getPitch() + 1);
pitchChanged = pressed;
}
private void pitchInstrumentDown(final boolean pressed) {
setPitch(getPitch() - 1);
pitchChanged = pressed;
}


@Override
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) {
Expand Down Expand Up @@ -314,6 +309,8 @@ public void onOptionsOpen() {
setFocused(null);
minecraft.pushGuiLayer(optionsScreen);

initPitch(this::setPitch);

isOptionsScreenActive = true;
}
public void onOptionsClose() {
Expand Down

0 comments on commit 28b4dd3

Please sign in to comment.