Skip to content

Commit 01cc081

Browse files
committed
Updated AutoFly & AutoEat
1 parent 171742c commit 01cc081

3 files changed

Lines changed: 223 additions & 15 deletions

File tree

src/main/java/net/wurstclient/hacks/AutoEatHack.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,13 @@ private boolean shouldEat()
255255
if(!MC.player.canEat(false))
256256
return false;
257257

258+
boolean autoFlyActive = WURST.getHax().autoFlyHack.isEnabled();
259+
258260
if(!eatWhileWalking.isChecked()
259-
&& (MC.player.zza != 0 || MC.player.xxa != 0))
261+
&& !autoFlyActive && (MC.player.zza != 0 || MC.player.xxa != 0))
260262
return false;
261263

262-
if(isClickable(MC.hitResult))
264+
if(!autoFlyActive && isClickable(MC.hitResult))
263265
return false;
264266

265267
return true;

src/main/java/net/wurstclient/hacks/AutoFlyHack.java

Lines changed: 170 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ public String toString()
404404
new SliderSetting("Chunk trail: Single-wall nudge (blocks/step)", 12, 4,
405405
32, 1, SliderSetting.ValueDisplay.INTEGER);
406406
private boolean flightOverridesApplied;
407+
private double chunkTrailSpeedScale = 1.0;
407408
private double lastYForProgress = Double.NaN;
408409
private long lastVerticalProgressMs;
409410
private boolean verticalAssistActive;
@@ -738,6 +739,9 @@ public void onUpdate()
738739
if(checkDisableOnDamage())
739740
return;
740741

742+
if(handleAutoEatPause())
743+
return;
744+
741745
if(allowManualAdjust.isChecked() && isManualInputActive())
742746
{
743747
beginManualAdjust(MC.player.position());
@@ -2107,8 +2111,10 @@ private void applyFlightSettings()
21072111
private void applyFlightSpeed()
21082112
{
21092113
var flight = WURST.getHax().flightHack;
2114+
double scale = routeType.getSelected() == RouteType.CHUNKS
2115+
? chunkTrailSpeedScale : 1.0;
21102116
double desired = Math.min(flight.horizontalSpeed.getMaximum(),
2111-
flightSpeed.getValue());
2117+
flightSpeed.getValue() * MathUtils.clamp(scale, 0.2, 1.0));
21122118
flight.horizontalSpeed.setValue(desired);
21132119
}
21142120

@@ -2386,6 +2392,7 @@ private void applyChunkCorridorAssist()
23862392
{
23872393
if(MC.player == null || MC.level == null)
23882394
return;
2395+
chunkTrailSpeedScale = 1.0;
23892396

23902397
var chunks = WURST.getHax().newerNewChunksHack;
23912398
var oldTrail = chunks.getOldChunksLiveView();
@@ -2418,6 +2425,7 @@ private void applyChunkCorridorAssist()
24182425
}
24192426
if(!playerOnUsableGreen && nearbySafe != null)
24202427
{
2428+
chunkTrailSpeedScale = 0.35;
24212429
ChunkPos recoveryTargetChunk = nearbySafe;
24222430
if(chunkEdgeRecoveryAnchor != null && chunkEdgeRecoveryTicks > 0
24232431
&& isOldTrailNotNew(oldTrail, newSet, chunkEdgeRecoveryAnchor))
@@ -2557,15 +2565,16 @@ && isTargetStillAhead(chunkCorridorTargetPos, playerForwardProgress)
25572565
}
25582566
if(recoveryTarget != null)
25592567
{
2568+
chunkTrailSpeedScale = 0.35;
25602569
chunkNoTargetTicks++;
25612570
chunkTrailEndConfirmStrikes = 0;
25622571
chunkCorridorTargetPos = recoveryTarget;
25632572
return;
25642573
}
25652574
}
25662575

2567-
// Keep moving forward even without detected borders. Use current
2568-
// forward axis (or look direction) to set a provisional target.
2576+
// If the green corridor has not caught up yet, slow down hard and
2577+
// favor nearby known old chunks instead of charging into red.
25692578
chunkNoTargetTicks++;
25702579
if(chunkCorridorTargetPos != null && isTargetStillAhead(
25712580
chunkCorridorTargetPos, playerForwardProgress))
@@ -2580,34 +2589,45 @@ && isTargetStillAhead(chunkCorridorTargetPos, playerForwardProgress)
25802589
chunkCorridorTargetPos = null;
25812590
return;
25822591
}
2583-
double lead = CHUNK_NO_TARGET_FORWARD_LEAD_BLOCKS;
2584-
// After grace, extend the lead to keep cruising smoothly.
2585-
if(chunkNoTargetTicks > CHUNK_NO_TARGET_GRACE_TICKS)
2586-
lead = Math.max(lead, 32.0);
2587-
Vec3 provisional = playerPos.add(axis.normalize().scale(lead));
2588-
2589-
// Single/both-wall avoidance: nudge away from red walls and
2590-
// center between them when both are detected.
25912592
Vec3 right = new Vec3(-axis.z, 0.0, axis.x);
25922593
ChunkPos pChunk = ChunkPos.containing(MC.player.blockPosition());
25932594
int leftDist = distanceToNearestNewWall(newSet, pChunk, right, -1,
25942595
CHUNK_WALL_SCAN_RADIUS);
25952596
int rightDist = distanceToNearestNewWall(newSet, pChunk, right, 1,
25962597
CHUNK_WALL_SCAN_RADIUS);
2598+
Vec3 looseOldTarget = selectLooseOldTrailTarget(oldTrail, newSet,
2599+
playerPos, pChunk, axis, right, playerForwardProgress);
2600+
double lead = Math.min(CHUNK_NO_TARGET_FORWARD_LEAD_BLOCKS, 10.0);
2601+
chunkTrailSpeedScale =
2602+
chunkNoTargetTicks > CHUNK_NO_TARGET_GRACE_TICKS ? 0.2 : 0.35;
2603+
Vec3 provisional = looseOldTarget != null ? looseOldTarget
2604+
: playerPos.add(axis.normalize().scale(lead));
2605+
2606+
// Single/both-wall avoidance: nudge away from red walls and
2607+
// center between them when both are detected.
25972608
double lateral = 0.0;
25982609
if(leftDist > 0 && rightDist > 0)
25992610
{
26002611
double centerOffsetChunks = (rightDist - leftDist) * 0.5;
26012612
lateral +=
26022613
Math.max(-24.0, Math.min(24.0, centerOffsetChunks * 16.0));
2614+
int nearestWall = Math.min(leftDist, rightDist);
2615+
if(nearestWall <= 2)
2616+
chunkTrailSpeedScale = Math.min(chunkTrailSpeedScale, 0.35);
26032617
}else
26042618
{
26052619
int guard = Math.max(3, CHUNK_MIN_CORRIDOR_THICKNESS);
26062620
double nudge = getSingleWallNudgeStrength();
26072621
if(leftDist > 0 && leftDist <= guard)
2622+
{
26082623
lateral += (guard + 1 - leftDist) * nudge; // push right
2624+
chunkTrailSpeedScale = Math.min(chunkTrailSpeedScale, 0.35);
2625+
}
26092626
if(rightDist > 0 && rightDist <= guard)
2627+
{
26102628
lateral -= (guard + 1 - rightDist) * nudge; // push left
2629+
chunkTrailSpeedScale = Math.min(chunkTrailSpeedScale, 0.35);
2630+
}
26112631
}
26122632
if(Math.abs(lateral) > 0.01)
26132633
provisional = provisional.add(right.normalize().scale(lateral));
@@ -2676,6 +2696,7 @@ && isTargetStillAhead(chunkCorridorTargetPos, playerForwardProgress)
26762696
public void clearChunkCorridorAssist()
26772697
{
26782698
chunkAssistActive = false;
2699+
chunkTrailSpeedScale = 1.0;
26792700
chunkCorridorAnchor = null;
26802701
chunkCorridorOrigin = null;
26812702
chunkCorridorHeading = null;
@@ -3007,6 +3028,84 @@ private Vec3 selectChunkCorridorTargetPos(java.util.Set<ChunkPos> oldTrail,
30073028
return null;
30083029
}
30093030

3031+
private Vec3 selectLooseOldTrailTarget(java.util.Set<ChunkPos> oldTrail,
3032+
java.util.Set<ChunkPos> newChunks, Vec3 playerPos, ChunkPos playerChunk,
3033+
Vec3 forward, Vec3 right, double playerForwardProgress)
3034+
{
3035+
if(oldTrail == null || oldTrail.isEmpty() || playerPos == null
3036+
|| playerChunk == null || forward == null || right == null)
3037+
return null;
3038+
3039+
Vec3 flatForward = new Vec3(forward.x, 0.0, forward.z);
3040+
if(flatForward.lengthSqr() < 1.0E-6)
3041+
return null;
3042+
flatForward = flatForward.normalize();
3043+
3044+
ChunkPos best = null;
3045+
double bestScore = Double.NEGATIVE_INFINITY;
3046+
int forwardLimit = Math.max(2, getAheadScanChunks());
3047+
int sideLimit = Math.max(1, getSideScanHalfWidth() + 2);
3048+
for(int f = 0; f <= forwardLimit; f++)
3049+
{
3050+
ChunkPos front = stepChunk(playerChunk, flatForward, f);
3051+
for(int w = -sideLimit; w <= sideLimit; w++)
3052+
{
3053+
ChunkPos candidate = stepChunk(front, right, w);
3054+
if(!isOldTrailNotNew(oldTrail, newChunks, candidate))
3055+
continue;
3056+
3057+
Vec3 center = Vec3.atCenterOf(chunkCenter(candidate));
3058+
Vec3 delta = center.subtract(playerPos);
3059+
Vec3 dir = new Vec3(delta.x, 0.0, delta.z);
3060+
if(dir.lengthSqr() < 1.0E-6)
3061+
continue;
3062+
dir = dir.normalize();
3063+
3064+
double along = dir.dot(flatForward);
3065+
if(along < CHUNK_MIN_FORWARD_DOT)
3066+
continue;
3067+
3068+
double targetProgress =
3069+
chunkCorridorOrigin != null ? projectAlongHeading(center,
3070+
chunkCorridorOrigin, flatForward) : Double.NaN;
3071+
if(!Double.isNaN(playerForwardProgress)
3072+
&& !Double.isNaN(targetProgress)
3073+
&& targetProgress < playerForwardProgress
3074+
- CHUNK_BACKTRACK_BLOCK_TOLERANCE)
3075+
continue;
3076+
3077+
double dist = Math.max(1.0, Math.hypot(delta.x, delta.z));
3078+
double lateral = Math.abs(dir.dot(right));
3079+
int leftWallDist = distanceToNearestNewWall(newChunks,
3080+
candidate, right, -1, CHUNK_WALL_SCAN_RADIUS);
3081+
int rightWallDist = distanceToNearestNewWall(newChunks,
3082+
candidate, right, 1, CHUNK_WALL_SCAN_RADIUS);
3083+
double wallScore = 0.0;
3084+
if(leftWallDist > 0 && rightWallDist > 0)
3085+
wallScore += Math.min(leftWallDist, rightWallDist) * 1.5
3086+
- Math.abs(leftWallDist - rightWallDist) * 2.0;
3087+
else if(leftWallDist > 0 || rightWallDist > 0)
3088+
wallScore += 1.0;
3089+
3090+
double score = along * 18.0 - lateral * 6.0 - dist * 0.12
3091+
+ wallScore - getRecentCorridorPenalty(candidate);
3092+
if(!Double.isNaN(playerForwardProgress)
3093+
&& !Double.isNaN(targetProgress))
3094+
score +=
3095+
Math.min(32.0, targetProgress - playerForwardProgress)
3096+
* 0.25;
3097+
3098+
if(score > bestScore)
3099+
{
3100+
bestScore = score;
3101+
best = candidate;
3102+
}
3103+
}
3104+
}
3105+
3106+
return best != null ? Vec3.atCenterOf(chunkCenter(best)) : null;
3107+
}
3108+
30103109
private static int distanceToNearestNewWall(
30113110
java.util.Set<ChunkPos> newChunks, ChunkPos from, Vec3 right,
30123111
int directionSign, int maxSteps)
@@ -3857,6 +3956,31 @@ private void beginManualAdjust(Vec3 playerPos)
38573956
PathProcessor.releaseControls();
38583957
}
38593958

3959+
private boolean handleAutoEatPause()
3960+
{
3961+
if(!WURST.getHax().autoEatHack.isEating())
3962+
return false;
3963+
3964+
long now = System.currentTimeMillis();
3965+
ensureFlightEnabled();
3966+
applyFlightSpeed();
3967+
PathProcessor.releaseControls();
3968+
resetAutoKeyFlags();
3969+
clearMovementKeys();
3970+
clearPathingState();
3971+
manualAdjustHold = false;
3972+
manualAdjustStartMs = 0L;
3973+
manualAdjustStartPos = null;
3974+
lastProgressMs = now;
3975+
lastProgressDist = Double.NaN;
3976+
lastMovePos = MC.player.position();
3977+
lastMoveMs = now;
3978+
lastHorizPos = lastMovePos;
3979+
lastHorizMoveMs = now;
3980+
lastAutoControlMs = 0L;
3981+
return true;
3982+
}
3983+
38603984
private void handleManualAdjust()
38613985
{
38623986
if(MC.player == null)
@@ -3983,6 +4107,41 @@ else if(key == MC.options.keyShift)
39834107
autoKeyShiftDown = down;
39844108
}
39854109

4110+
public boolean isProvidingAutoFlyInput()
4111+
{
4112+
return isEnabled() && anyAutoKeyDown();
4113+
}
4114+
4115+
public boolean isAutoKeyUpDown()
4116+
{
4117+
return autoKeyUpDown;
4118+
}
4119+
4120+
public boolean isAutoKeyDownDown()
4121+
{
4122+
return autoKeyDownDown;
4123+
}
4124+
4125+
public boolean isAutoKeyLeftDown()
4126+
{
4127+
return autoKeyLeftDown;
4128+
}
4129+
4130+
public boolean isAutoKeyRightDown()
4131+
{
4132+
return autoKeyRightDown;
4133+
}
4134+
4135+
public boolean isAutoKeyJumpDown()
4136+
{
4137+
return autoKeyJumpDown;
4138+
}
4139+
4140+
public boolean isAutoKeyShiftDown()
4141+
{
4142+
return autoKeyShiftDown;
4143+
}
4144+
39864145
private void resetAutoKeyFlags()
39874146
{
39884147
autoKeyUpDown = false;

src/main/java/net/wurstclient/hacks/FlightHack.java

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.tags.FluidTags;
1313
import net.minecraft.util.Mth;
1414
import net.minecraft.world.level.block.state.BlockState;
15+
import net.minecraft.world.phys.Vec2;
1516
import net.minecraft.world.phys.Vec3;
1617
import net.wurstclient.Category;
1718
import net.wurstclient.SearchTags;
@@ -227,19 +228,24 @@ public void onUpdate()
227228

228229
double vSpeed = getActualVerticalSpeed();
229230

230-
if(MC.options.keyJump.isDown())
231+
AutoFlyHack autoFly = WURST.getHax().autoFlyHack;
232+
boolean autoJump = autoFly.isAutoKeyJumpDown();
233+
boolean autoShift = autoFly.isAutoKeyShiftDown();
234+
if(MC.options.keyJump.isDown() || autoJump)
231235
player.addDeltaMovement(new Vec3(0, vSpeed, 0));
232236

233237
boolean shiftActuallyDown =
234238
IKeyMapping.get(MC.options.keyShift).isActuallyDown();
235239
boolean allowShiftInThisContext =
236240
!ignoreShiftInGuis.isChecked() || MC.screen == null;
237-
if(shiftActuallyDown && allowShiftInThisContext)
241+
if((shiftActuallyDown && allowShiftInThisContext) || autoShift)
238242
{
239243
MC.options.keyShift.setDown(false);
240244
player.addDeltaMovement(new Vec3(0, -vSpeed, 0));
241245
}
242246

247+
applyAutoFlyHorizontalVelocity(player, autoFly);
248+
243249
if(isAntiKickEnabled())
244250
doAntiKick();
245251

@@ -255,6 +261,47 @@ public void onUpdate()
255261
}
256262
}
257263

264+
private void applyAutoFlyHorizontalVelocity(LocalPlayer player,
265+
AutoFlyHack autoFly)
266+
{
267+
if(!autoFly.isProvidingAutoFlyInput())
268+
return;
269+
270+
Vec2 moveVector =
271+
player.input != null ? player.input.getMoveVector() : Vec2.ZERO;
272+
if(moveVector.lengthSquared() > 1.0E-5F)
273+
return;
274+
275+
double forwardImpulse = 0.0;
276+
double sideImpulse = 0.0;
277+
if(autoFly.isAutoKeyUpDown())
278+
forwardImpulse += 1.0;
279+
if(autoFly.isAutoKeyDownDown())
280+
forwardImpulse -= 1.0;
281+
if(autoFly.isAutoKeyLeftDown())
282+
sideImpulse += 1.0;
283+
if(autoFly.isAutoKeyRightDown())
284+
sideImpulse -= 1.0;
285+
286+
if(forwardImpulse == 0.0 && sideImpulse == 0.0)
287+
return;
288+
289+
Vec3 forward =
290+
Vec3.directionFromRotation(0.0F, player.getYRot()).normalize();
291+
forward = new Vec3(forward.x, 0.0, forward.z);
292+
if(forward.lengthSqr() < 1.0E-6)
293+
return;
294+
forward = forward.normalize();
295+
Vec3 right = new Vec3(-forward.z, 0.0, forward.x);
296+
Vec3 movement =
297+
forward.scale(forwardImpulse).add(right.scale(sideImpulse));
298+
if(movement.lengthSqr() < 1.0E-6)
299+
return;
300+
301+
double speed = horizontalSpeed.getValue();
302+
player.addDeltaMovement(movement.normalize().scale(speed));
303+
}
304+
258305
private void syncNoSlowdownVineIgnore()
259306
{
260307
NoSlowdownHack noSlowdown = WURST.getHax().noSlowdownHack;

0 commit comments

Comments
 (0)