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: #321 Camera Controls: Make . and 0 directly active, and double press up/down keys work with right Alt key #322

Merged
merged 1 commit into from
Aug 11, 2024
Merged
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 @@ -111,19 +111,21 @@ private boolean keyListener() {
|| (isDownKeyPressed && isRightAltPressed && !isLeftAltPressed);
boolean isCenterCameraKeyPressed = KeyUtils.isAnyPressed(kbh.cameraControlsCenterCamera);

boolean isStraightUpKeyPressed = KeyUtils.isAnyPressed(kbh.cameraControlsStraightUp) || straightUpDoubleClick.canBeTriggered();
boolean isStraightDownKeyPressed = KeyUtils.isAnyPressed(kbh.cameraControlsStraightDown) || straightDownDoubleClick.canBeTriggered();
boolean isStraightUpKeyPressed = KeyUtils.isAnyPressed(kbh.cameraControlsStraightUp);
boolean isUpKeyDoublePressedWithRightAlt = isRightAltPressed && straightUpDoubleClick.canBeTriggered();
boolean isStraightDownKeyPressed = KeyUtils.isAnyPressed(kbh.cameraControlsStraightDown);
boolean isDownKeyDoublePressedWithRightAlt = isRightAltPressed && straightDownDoubleClick.canBeTriggered();

straightUpDoubleClick.updateStateForNextTick();
straightDownDoubleClick.updateStateForNextTick();

// these two blocks of logic should be ahead of the normal up/down logic
if (isStraightUpKeyPressed) {
if (isStraightUpKeyPressed || isUpKeyDoublePressedWithRightAlt) {
rotateCameraTo(Orientation.UP);
return true;
}

if (isStraightDownKeyPressed) {
if (isStraightDownKeyPressed || isDownKeyDoublePressedWithRightAlt) {
rotateCameraTo(Orientation.DOWN);
return true;
}
Expand Down Expand Up @@ -210,7 +212,7 @@ private void rotateCameraBy(float angle, RotatingDirection direction) {
minecraftClient.player.changeLookDirection(horizontalAngleDelta, verticalAngleDelta);

// log and speak new facing direction
log.debug("Rotating camera by x:%d y:%d".formatted((int) horizontalAngleDelta, (int) verticalAngleDelta));
log.debug("Rotating camera by x:%d y:%d".formatted((int) horizontalAngleDelta, (int) verticalAngleDelta));

PlayerPositionUtils pUtil = new PlayerPositionUtils(this.minecraftClient);
String horizontalDirection = pUtil.getHorizontalFacingDirectionInCardinal();
Expand All @@ -236,7 +238,7 @@ private void rotateCameraTo(Orientation direction) {
minecraftClient.player.lookAt(EntityAnchorArgumentType.EntityAnchor.FEET, targetBlockPosition);

// log and speak new facing direction
log.debug("Rotating camera to: %s".formatted(direction.name()));
log.debug("Rotating camera to: %s".formatted(direction.name()));

PlayerPositionUtils pUtil = new PlayerPositionUtils(this.minecraftClient);

Expand Down