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 new sneak parameter to the safe walk module #3879

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -28,7 +28,8 @@ public class InputCommand extends Command {
mc.options.jumpKey, "jump",
mc.options.sneakKey, "sneak",
mc.options.useKey, "use",
mc.options.attackKey, "attack"
mc.options.attackKey, "attack",
mc.options.sprintKey, "sprint"
);

public InputCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,108 @@
package meteordevelopment.meteorclient.systems.modules.movement;

import meteordevelopment.meteorclient.events.entity.player.ClipAtLedgeEvent;
import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.renderer.ShapeMode;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.util.math.Box;

public class SafeWalk extends Module {
private final SettingGroup swGeneral = settings.getDefaultGroup();

private final Setting<Boolean> sneak = swGeneral.add(new BoolSetting.Builder()
.name("sneak")
.description("Sneak when approaching edge of block.")
.defaultValue(false)
.build());

private final Setting<Boolean> safeSneak = swGeneral.add(new BoolSetting.Builder()
.name("safe-sneak")
.description("Prevent you to falling if sneak doesn't trigger correctly.")
.defaultValue(true)
.visible(() -> this.sneak.get())
.build());

private final Setting<Boolean> sneakSprint = swGeneral.add(new BoolSetting.Builder()
.name("sneak-on-sprint")
.description("Keep sneak on sprinting key pressed.")
.defaultValue(true)
.visible(() -> this.sneak.get())
.build());

private final Setting<Double> edgeDistance = swGeneral.add(new DoubleSetting.Builder()
.name("edge-distance")
.description("Distance offset before reaching an edge.")
.defaultValue(0.30)
.sliderRange(0.00, 0.30)
.decimalPlaces(2)
.visible(() -> this.sneak.get())
.build());

private final Setting<Boolean> renderEdgeDistance = swGeneral.add(new BoolSetting.Builder()
.name("render")
.description("Render edge distance helper.")
.defaultValue(false)
.visible(() -> this.sneak.get())
.build());

private final Setting<Boolean> renderPlayerBox = swGeneral.add(new BoolSetting.Builder()
.name("render-player-box")
.description("Render player box helper.")
.defaultValue(true)
.visible(() -> this.renderEdgeDistance.get())
o0sh4d0w0o marked this conversation as resolved.
Show resolved Hide resolved
.build());

public SafeWalk() {
super(Categories.Movement, "safe-walk", "Prevents you from walking off blocks.");
}

@EventHandler
private void onClipAtLedge(ClipAtLedgeEvent event) {
if (!mc.player.isSneaking()) event.setClip(true);
if (sneak.get()) {
boolean closeToEdge = false;
boolean isSprinting = this.sneakSprint.get() ? false : mc.options.sprintKey.isPressed();

Box playerBox = mc.player.getBoundingBox();
Box adjustedBox = this.getAdjustedPlayerBox(playerBox);

if (mc.world.isSpaceEmpty(mc.player, adjustedBox) && mc.player.isOnGround())
closeToEdge = true;

if (!isSprinting) {
if (closeToEdge == true) {
mc.player.input.sneaking = true;
} else if (this.safeSneak.get()) {
event.setClip(true);
}
}
Wide-Cat marked this conversation as resolved.
Show resolved Hide resolved
} else {
if (!mc.player.isSneaking())
event.setClip(true);
}

}

private Box getAdjustedPlayerBox(Box playerBox) {
return playerBox.stretch(0, -mc.player.getStepHeight(), 0)
.expand(-edgeDistance.get(), 0, -edgeDistance.get());
}

@EventHandler
private void onRender(Render3DEvent event) {
if (this.renderEdgeDistance.get()) {
o0sh4d0w0o marked this conversation as resolved.
Show resolved Hide resolved
Box playerBox = mc.player.getBoundingBox();
Box adjustedBox = getAdjustedPlayerBox(playerBox);

event.renderer.box(adjustedBox, Color.BLUE, Color.RED, ShapeMode.Lines, 0);

if (this.renderPlayerBox.get()) {
event.renderer.box(playerBox, Color.BLUE, Color.GREEN, ShapeMode.Lines, 0);
}
}

}
}