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

Added the 'change speed with scroll wheel' functionality of the freecam module to the flight module #4893

Open
wants to merge 1 commit into
base: master
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package meteordevelopment.meteorclient.systems.modules.movement;

import meteordevelopment.meteorclient.events.meteor.MouseScrollEvent;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.mixin.ClientPlayerEntityAccessor;
Expand Down Expand Up @@ -43,6 +44,15 @@ public class Flight extends Module {
.build()
);

private final Setting<Double> speedScrollSensitivity = sgGeneral.add(new DoubleSetting.Builder()
.name("speed-scroll-sensitivity")
.description("Allows you to change flight speed using scroll wheel. 0 to disable.")
.defaultValue(0.0)
.min(0.0)
.sliderMax(2.0)
.build()
);

private final Setting<Boolean> verticalSpeedMatch = sgGeneral.add(new BoolSetting.Builder()
.name("vertical-speed-match")
.description("Matches your vertical speed to your horizontal speed, otherwise uses vanilla ratio.")
Expand Down Expand Up @@ -120,6 +130,17 @@ private void onPreTick(TickEvent.Pre event) {
lastYaw = currentYaw;
}

@EventHandler
private void onMouseScroll(MouseScrollEvent event) {
if (speedScrollSensitivity.get() > 0 && mc.currentScreen == null) {
double newSpeed = speed.get() + event.value * 0.25 * (speedScrollSensitivity.get() * speed.get());
if (newSpeed < 0.01) newSpeed = 0.01; // Ensuring the speed doesn't become too slow.

speed.set(newSpeed); // Update the speed setting with the new value.
event.cancel();
}
}

@EventHandler
private void onPostTick(TickEvent.Post event) {
if (delayLeft > 0) delayLeft--;
Expand Down
Loading