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

Add Camera #875

Open
wants to merge 2 commits into
base: 2.15-dev
Choose a base branch
from
Open
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
27 changes: 21 additions & 6 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;
KgDW marked this conversation as resolved.
Show resolved Hide resolved
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(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));
KgDW marked this conversation as resolved.
Show resolved Hide resolved
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()));
}
}
KgDW marked this conversation as resolved.
Show resolved Hide resolved
}

private boolean canMotion() {
Expand Down
Loading