Skip to content

Commit

Permalink
Added the 'change speed with scroll wheel' functionality of the freec…
Browse files Browse the repository at this point in the history
…am module to the flight module
  • Loading branch information
4Wiesel20 committed Sep 12, 2024
1 parent e4fc59e commit 849bab4
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit 849bab4

Please sign in to comment.