Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Add Camera
Browse files Browse the repository at this point in the history
  • Loading branch information
KgDW committed Dec 21, 2024
1 parent ab78b54 commit 19009ff
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/main/java/keystrokesmod/module/impl/render/MotionCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ public class MotionCamera extends Module {
private final SliderSetting maxOffset;
private final ButtonSetting smooth;
private final ButtonSetting onlyThirdPerson;
private final ButtonSetting camera;
private final ButtonSetting scaffold;
private final ButtonSetting notWhileTower;

private double y = Double.NaN;
private final Animation animation = new Animation(Easing.EASE_OUT_CIRC, 300);
private final Animation animation = new Animation(Easing.EASE_OUT_CUBIC, 1000);

public MotionCamera() {
super("MotionCamera", category.render);
this.registerSetting(offset = new SliderSetting("Offset", 0, -2, 2, 0.1));
this.registerSetting(offset = new SliderSetting("Offset", 0, -1, 1, 0.01));
this.registerSetting(maxOffset = new SliderSetting("Max offset", 1.5, 0, 5, 0.1));
this.registerSetting(smooth = new ButtonSetting("Smooth", true));
this.registerSetting(onlyThirdPerson = new ButtonSetting("Only third person", true));
this.registerSetting(camera = new ButtonSetting("Camera", true));
this.registerSetting(scaffold = new ButtonSetting("Scaffold", false));
this.registerSetting(notWhileTower = new ButtonSetting("Not while tower", true, scaffold::isToggled));
}
Expand Down Expand Up @@ -60,11 +62,24 @@ public void onEyeHeightEvent(@NotNull EyeHeightEvent event) {
}

double curY = event.getY();
double targetY = y + offset.getInput();
animation.run(Utils.limit(targetY, curY - maxOffset.getInput() + offset.getInput(), curY + maxOffset.getInput() + offset.getInput()));
if (smooth.isToggled())
targetY = animation.getValue();
event.setY(Utils.limit(targetY, curY - maxOffset.getInput() + offset.getInput(), curY + maxOffset.getInput() + offset.getInput()));
double targetY = mc.thePlayer.posY + offset.getInput();

if (camera.isToggled() && mc.gameSettings.thirdPersonView != 0) {
if (Double.isNaN(y)) {
animation.setValue(y);
}
animation.run(Utils.limit(targetY, curY - maxOffset.getInput(), curY + maxOffset.getInput()));

if (smooth.isToggled()) {
targetY = animation.getValue();

event.setY(Utils.limit(targetY, curY - maxOffset.getInput(), curY + maxOffset.getInput()));
} else {
animation.setValue(y);

event.setY(Utils.limit(y + offset.getInput(), curY - maxOffset.getInput(), curY + maxOffset.getInput()));
}
}
}

private boolean canMotion() {
Expand Down

0 comments on commit 19009ff

Please sign in to comment.