Skip to content

Commit 1d1b168

Browse files
committed
More Autofly Fixes
1 parent 8f4a777 commit 1d1b168

2 files changed

Lines changed: 51 additions & 41 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,6 +3823,9 @@ private void restoreVerticalIfBoosted()
38233823

38243824
private boolean shouldRepath(Vec3 playerPos, double distHoriz)
38253825
{
3826+
if(isDirectionalForwardMode())
3827+
return false;
3828+
38263829
// Recovery pathing is designed for ground navigation. In mid-air it can
38273830
// cause oscillation/stalls, so keep using direct flight controls.
38283831
if(MC.player != null && !MC.player.onGround())
@@ -3845,6 +3848,8 @@ private void startRecoveryPath(Vec3 playerPos)
38453848
{
38463849
if(MC.level == null || MC.player == null)
38473850
return;
3851+
if(isDirectionalForwardMode())
3852+
return;
38483853

38493854
lastRepathMs = System.currentTimeMillis();
38503855
stuckRepathCount++;
@@ -3929,6 +3934,12 @@ private void clearPathingState()
39293934
lastProgressDist = Double.NaN;
39303935
}
39313936

3937+
private boolean isDirectionalForwardMode()
3938+
{
3939+
return commandForwardUnlimited
3940+
&& routeType.getSelected() != RouteType.CHUNKS;
3941+
}
3942+
39323943
private void resetAfterTickGap(long now)
39333944
{
39343945
Vec3 playerPos = MC.player.position();

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

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public final class PearlDropHack extends Hack
5858
private static final double HONEY_SHAPE_INSET = 0.0625;
5959
private static final double HONEY_SHAPE_TOP = 0.9375;
6060

61-
private static final Direction[] HORIZONTAL_DIRECTIONS = {
62-
Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST};
61+
private static final Direction[] HORIZONTAL_DIRECTIONS =
62+
{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST};
6363

6464
private BlockPos nearestColumn;
6565
private BlockPos nearestHoney;
@@ -144,8 +144,8 @@ public void onRender(PoseStack matrixStack, float partialTicks)
144144
ready ? 0xE022FF66 : hasSolution ? 0xE0FFE066 : 0xE0FF5555;
145145
RenderUtils.drawSolidBox(matrixStack, new AABB(column), columnFill,
146146
false);
147-
RenderUtils.drawOutlinedBox(matrixStack, new AABB(column), columnOutline,
148-
false);
147+
RenderUtils.drawOutlinedBox(matrixStack, new AABB(column),
148+
columnOutline, false);
149149

150150
if(honey != null)
151151
{
@@ -240,26 +240,27 @@ private void updateSolution(boolean force)
240240
for(int i = 0; i < checks; i++)
241241
{
242242
SetupCandidate setup = setups.get(i);
243-
SimulationResult currentResult =
244-
simulateTrajectory(currentYaw, currentPitch, setup.column,
245-
setup.honey);
243+
SimulationResult currentResult = simulateTrajectory(currentYaw,
244+
currentPitch, setup.column, setup.honey);
246245

247246
if(currentResult != null)
248247
{
249-
TrajectorySolution solution = new TrajectorySolution(setup.column,
250-
setup.honey, currentYaw, currentPitch, currentResult.score,
251-
0);
248+
TrajectorySolution solution =
249+
new TrajectorySolution(setup.column, setup.honey,
250+
currentYaw, currentPitch, currentResult.score, 0);
252251

253-
if(activeSolution == null || solution.score < activeSolution.score)
252+
if(activeSolution == null
253+
|| solution.score < activeSolution.score)
254254
activeSolution = solution;
255255
}
256256

257-
TrajectorySolution nearbySolution = solveNearCurrentAim(setup.column,
258-
setup.honey, currentYaw, currentPitch);
257+
TrajectorySolution nearbySolution = solveNearCurrentAim(
258+
setup.column, setup.honey, currentYaw, currentPitch);
259259

260260
if(nearbySolution == null)
261261
continue;
262-
if(bestSolution == null || nearbySolution.score < bestSolution.score)
262+
if(bestSolution == null
263+
|| nearbySolution.score < bestSolution.score)
263264
bestSolution = nearbySolution;
264265
}
265266

@@ -278,7 +279,8 @@ private void updateSolution(boolean force)
278279
}
279280

280281
private void addSetupIfValid(ArrayList<SetupCandidate> setups, Vec3 eyes,
281-
BlockPos column, BlockPos honey, ArrayList<BlockPos> standingHoneyBlocks)
282+
BlockPos column, BlockPos honey,
283+
ArrayList<BlockPos> standingHoneyBlocks)
282284
{
283285
if(!isHoney(honey))
284286
return;
@@ -324,7 +326,8 @@ private void addHoneyBlockAt(ArrayList<BlockPos> honeyBlocks, double x,
324326
honeyBlocks.add(pos.immutable());
325327
}
326328

327-
private boolean containsBlockPos(ArrayList<BlockPos> positions, BlockPos pos)
329+
private boolean containsBlockPos(ArrayList<BlockPos> positions,
330+
BlockPos pos)
328331
{
329332
for(BlockPos current : positions)
330333
{
@@ -335,8 +338,8 @@ private boolean containsBlockPos(ArrayList<BlockPos> positions, BlockPos pos)
335338
return false;
336339
}
337340

338-
private TrajectorySolution solveNearCurrentAim(BlockPos column, BlockPos honey,
339-
float currentYaw, float currentPitch)
341+
private TrajectorySolution solveNearCurrentAim(BlockPos column,
342+
BlockPos honey, float currentYaw, float currentPitch)
340343
{
341344
SearchResult best = null;
342345

@@ -346,8 +349,8 @@ private TrajectorySolution solveNearCurrentAim(BlockPos column, BlockPos honey,
346349
if(best == null)
347350
return null;
348351

349-
best = searchRotations(column, honey, currentYaw, currentPitch, best.yaw,
350-
best.pitch, REFINE_RANGE, REFINE_STEP, best);
352+
best = searchRotations(column, honey, currentYaw, currentPitch,
353+
best.yaw, best.pitch, REFINE_RANGE, REFINE_STEP, best);
351354

352355
SimulationResult result =
353356
simulateTrajectory(best.yaw, best.pitch, column, honey);
@@ -357,19 +360,19 @@ private TrajectorySolution solveNearCurrentAim(BlockPos column, BlockPos honey,
357360
double aimError =
358361
getAngleDifference(currentYaw, currentPitch, best.yaw, best.pitch);
359362
double score = result.score + aimError * 0.08;
360-
return new TrajectorySolution(column, honey, best.yaw, best.pitch, score,
361-
aimError);
363+
return new TrajectorySolution(column, honey, best.yaw, best.pitch,
364+
score, aimError);
362365
}
363366

364367
private SearchResult searchRotations(BlockPos column, BlockPos honey,
365-
float currentYaw, float currentPitch, float centerYaw, float centerPitch,
366-
double range, double step, SearchResult best)
368+
float currentYaw, float currentPitch, float centerYaw,
369+
float centerPitch, double range, double step, SearchResult best)
367370
{
368-
for(double yawOffset = -range; yawOffset <= range + 1.0E-7;
369-
yawOffset += step)
371+
for(double yawOffset = -range; yawOffset <= range + 1.0E-7; yawOffset +=
372+
step)
370373
{
371-
for(double pitchOffset = -range; pitchOffset <= range + 1.0E-7;
372-
pitchOffset += step)
374+
for(double pitchOffset = -range; pitchOffset <= range
375+
+ 1.0E-7; pitchOffset += step)
373376
{
374377
float yaw = wrapDegrees((float)(centerYaw + yawOffset));
375378
float pitch = (float)(centerPitch + pitchOffset);
@@ -440,10 +443,8 @@ private CaptureResult getColumnCapture(Vec3 start, Vec3 end, Vec3 velocity,
440443
BlockPos column, int tick)
441444
{
442445
AABB captureBox = new AABB(column.getX() + 0.5 - COLUMN_CAPTURE_RADIUS,
443-
column.getY() + 0.03,
444-
column.getZ() + 0.5 - COLUMN_CAPTURE_RADIUS,
445-
column.getX() + 0.5 + COLUMN_CAPTURE_RADIUS,
446-
column.getY() + 0.97,
446+
column.getY() + 0.03, column.getZ() + 0.5 - COLUMN_CAPTURE_RADIUS,
447+
column.getX() + 0.5 + COLUMN_CAPTURE_RADIUS, column.getY() + 0.97,
447448
column.getZ() + 0.5 + COLUMN_CAPTURE_RADIUS);
448449

449450
Double hit = getSegmentBoxIntersection(start, end, captureBox);
@@ -457,8 +458,8 @@ private CaptureResult getColumnCapture(Vec3 start, Vec3 end, Vec3 velocity,
457458
double dz = point.z - centerZ;
458459
double horizontalDistance = Math.sqrt(dx * dx + dz * dz);
459460
double speedPenalty = Math.max(0, velocity.length() - 0.36) * 0.18;
460-
double verticalPenalty = Math.abs(point.y - (column.getY() + 0.45))
461-
* 0.08;
461+
double verticalPenalty =
462+
Math.abs(point.y - (column.getY() + 0.45)) * 0.08;
462463
double tickPenalty = tick * 0.0015;
463464
double score =
464465
horizontalDistance + speedPenalty + verticalPenalty + tickPenalty;
@@ -470,9 +471,8 @@ private boolean applyHoneySlide(Vec3 pos, Vec3 velocity, BlockPos honey,
470471
AABB honeyCollision)
471472
{
472473
AABB pearlBox = getPearlBox(pos);
473-
AABB honeyTouchBox = new AABB(honey.getX(), honey.getY(),
474-
honey.getZ(), honey.getX() + 1, honey.getY() + HONEY_SHAPE_TOP,
475-
honey.getZ() + 1);
474+
AABB honeyTouchBox = new AABB(honey.getX(), honey.getY(), honey.getZ(),
475+
honey.getX() + 1, honey.getY() + HONEY_SHAPE_TOP, honey.getZ() + 1);
476476

477477
if(!pearlBox.intersects(honeyTouchBox))
478478
return false;
@@ -532,9 +532,8 @@ private InteractionHand getPearlHand()
532532

533533
private AABB getPearlBox(Vec3 pos)
534534
{
535-
return new AABB(pos.x - PEARL_RADIUS, pos.y,
536-
pos.z - PEARL_RADIUS, pos.x + PEARL_RADIUS,
537-
pos.y + PEARL_HEIGHT, pos.z + PEARL_RADIUS);
535+
return new AABB(pos.x - PEARL_RADIUS, pos.y, pos.z - PEARL_RADIUS,
536+
pos.x + PEARL_RADIUS, pos.y + PEARL_HEIGHT, pos.z + PEARL_RADIUS);
538537
}
539538

540539
private AABB getHoneyCollisionBox(BlockPos honey)
@@ -722,4 +721,4 @@ private CaptureResult(Vec3 point, double score)
722721
this.score = score;
723722
}
724723
}
725-
}
724+
}

0 commit comments

Comments
 (0)