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

Add SafeWalk Min Depth Option Support #957

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version=0.15.7
fabric_version=0.92.0+1.20.1

# Mod Properties
mod_version = v7.41.1-MC1.20.1
mod_version = v7.41.1-MC1.20.1-Modified
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
33 changes: 31 additions & 2 deletions src/main/java/net/wurstclient/hacks/SafeWalkHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
@SearchTags({"safe walk"})
public final class SafeWalkHack extends Hack
{
private final SliderSetting minDepth = new SliderSetting("Min depth",
"Won't sneak if it isn't at least this deep.\n"
+ "Increase to stop SafeWalk from stucking on stairs.\n"
+ "Decrease to make SafeWalk sneak even at the edge of carpets.",
2.0, 0.1, 10, 0.1, ValueDisplay.DECIMAL.withSuffix("m"));

private final SliderSetting motionPrediction = new SliderSetting(
"Motion prediction",
"Predict your motion to sneak earlier.\n"
+ "If not stopping at edges, increase; If not stopping near a wall, decrease.",
2.0, 1, 5, 0.5, ValueDisplay.DECIMAL.withSuffix("x"));

private final CheckboxSetting sneak =
new CheckboxSetting("Sneak at edges", "Visibly sneak at edges.", false);

Expand All @@ -36,6 +48,8 @@ public SafeWalkHack()
{
super("SafeWalk");
setCategory(Category.MOVEMENT);
addSetting(minDepth);
addSetting(motionPrediction);
addSetting(sneak);
addSetting(edgeDistance);
}
Expand All @@ -54,10 +68,25 @@ protected void onDisable()
setSneaking(false);
}

public void onClipAtLedge(boolean clipping)
public boolean shouldClip()
{
ClientPlayerEntity player = MC.player;

Box box = player.getBoundingBox();
Box adjustedBox = box
.offset(player.getVelocity().multiply(motionPrediction.getValue()))
.stretch(0, -minDepth.getValue(), 0)
.expand(-edgeDistance.getValue(), 0, -edgeDistance.getValue());

return this.isEnabled() && MC.world.isSpaceEmpty(player, adjustedBox);
}

public void onClipAtLedge()
{
boolean clipping = false;

ClientPlayerEntity player = MC.player;

if(!isEnabled() || !sneak.isChecked() || !player.isOnGround())
{
if(sneaking)
Expand All @@ -67,7 +96,7 @@ public void onClipAtLedge(boolean clipping)
}

Box box = player.getBoundingBox();
Box adjustedBox = box.stretch(0, -player.stepHeight, 0)
Box adjustedBox = box.stretch(0, -minDepth.getValue(), 0)
.expand(-edgeDistance.getValue(), 0, -edgeDistance.getValue());

if(MC.world.isSpaceEmpty(player, adjustedBox))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected float getJumpVelocity()
protected boolean clipAtLedge()
{
return super.clipAtLedge()
|| WurstClient.INSTANCE.getHax().safeWalkHack.isEnabled();
|| WurstClient.INSTANCE.getHax().safeWalkHack.shouldClip();
}

/**
Expand All @@ -282,8 +282,7 @@ protected Vec3d adjustMovementForSneaking(Vec3d movement, MovementType type)
Vec3d result = super.adjustMovementForSneaking(movement, type);

if(movement != null)
WurstClient.INSTANCE.getHax().safeWalkHack
.onClipAtLedge(!movement.equals(result));
WurstClient.INSTANCE.getHax().safeWalkHack.onClipAtLedge();

return result;
}
Expand Down
Loading