Skip to content

Commit a18a343

Browse files
committed
Add tunnel bounce and stuck detection to ElytraFlyPlusPlus
Introduces a 'Tunnel Bounce' setting for improved movement in 1x2 tunnels and adds logic to detect and handle when the player is stuck. Refactors speed control to use PlayerMoveEvent, removes redundant velocity checks, and improves obstacle handling by pausing when stuck or in problematic conditions.
1 parent e7f1f3b commit a18a343

1 file changed

Lines changed: 66 additions & 19 deletions

File tree

src/main/java/dev/journey/PathSeeker/modules/utility/ElytraFlyPlusPlus.java

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
import baritone.api.BaritoneAPI;
44
import baritone.api.pathing.goals.GoalBlock;
5-
import dev.journey.PathSeeker.PathSeeker;
65
import static dev.journey.PathSeeker.utils.PathSeekerUtil.angleOnAxis;
76
import static dev.journey.PathSeeker.utils.PathSeekerUtil.distancePointToDirection;
87
import static dev.journey.PathSeeker.utils.PathSeekerUtil.positionInDirection;
98
import static dev.journey.PathSeeker.utils.PathSeekerUtil.yawToDirection;
109

10+
import dev.journey.PathSeeker.PathSeeker;
1111
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
1212
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
13+
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
1314
import meteordevelopment.meteorclient.events.packets.PacketEvent;
1415
import meteordevelopment.meteorclient.events.world.ChunkDataEvent;
1516
import meteordevelopment.meteorclient.events.world.PlaySoundEvent;
1617
import meteordevelopment.meteorclient.events.world.TickEvent;
18+
import meteordevelopment.meteorclient.mixininterface.IVec3d;
1719
import meteordevelopment.meteorclient.settings.BlockPosSetting;
1820
import meteordevelopment.meteorclient.settings.BoolSetting;
1921
import meteordevelopment.meteorclient.settings.DoubleSetting;
@@ -23,12 +25,12 @@
2325
import meteordevelopment.meteorclient.systems.modules.Module;
2426
import meteordevelopment.meteorclient.systems.modules.Modules;
2527
import meteordevelopment.meteorclient.systems.modules.player.ChestSwap;
26-
import meteordevelopment.meteorclient.utils.Utils;
2728
import meteordevelopment.meteorclient.utils.player.FindItemResult;
2829
import meteordevelopment.meteorclient.utils.player.InvUtils;
2930
import meteordevelopment.orbit.EventHandler;
3031
import net.minecraft.block.Blocks;
3132
import net.minecraft.entity.EquipmentSlot;
33+
import net.minecraft.entity.MovementType;
3234
import net.minecraft.item.ItemStack;
3335
import net.minecraft.item.Items;
3436
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
@@ -40,9 +42,13 @@
4042
import net.minecraft.util.math.BlockPos;
4143
import net.minecraft.util.math.ChunkPos;
4244
import net.minecraft.util.math.Vec3d;
45+
import meteordevelopment.meteorclient.settings.*;
46+
import meteordevelopment.meteorclient.systems.modules.world.Timer;
47+
import net.minecraft.network.packet.c2s.play.*;
4348

4449
import java.util.List;
4550

51+
4652
public class ElytraFlyPlusPlus extends Module {
4753

4854
private final SettingGroup sgGeneral = settings.getDefaultGroup();
@@ -63,11 +69,19 @@ public class ElytraFlyPlusPlus extends Module {
6369
.build()
6470
);
6571

72+
private final Setting<Boolean> tunnelBounce = sgGeneral.add(new BoolSetting.Builder()
73+
.name("Tunnel Bounce")
74+
.description("Allows you to bounce in 1x2 tunnels. This should not be on if you are not in a tunnel.")
75+
.defaultValue(false)
76+
.visible(() -> bounce.get() && motionYBoost.get())
77+
.build()
78+
);
79+
6680
private final Setting<Double> speed = sgGeneral.add(new DoubleSetting.Builder()
6781
.name("Speed")
6882
.description("The speed in blocks per second to keep you at.")
6983
.defaultValue(100.0)
70-
.range(10, 105)
84+
.sliderRange(20, 250)
7185
.visible(() -> bounce.get() && motionYBoost.get())
7286
.build()
7387
);
@@ -154,7 +168,7 @@ public class ElytraFlyPlusPlus extends Module {
154168

155169
private final Setting<Integer> targetY = sgObstaclePasser.add(new IntSetting.Builder()
156170
.name("Y Level")
157-
.description("The Y level to bounce at.")
171+
.description("The Y level to bounce at. This must be correct or bounce will not start properly.")
158172
.defaultValue(120)
159173
.visible(() -> bounce.get() && highwayObstaclePasser.get())
160174
.build()
@@ -217,12 +231,15 @@ public ElytraFlyPlusPlus() {
217231

218232
private boolean elytraToggled = false;
219233

234+
private Vec3d lastUnstuckPos;
235+
private int stuckTimer = 0;
236+
220237
@EventHandler
221238
private void onReceivePacket(PacketEvent.Receive event)
222239
{
223240
if (event.packet instanceof PlayerPositionLookS2CPacket packet)
224241
{
225-
onActivate();
242+
// onActivate();
226243
}
227244
else if (event.packet instanceof CloseScreenS2CPacket)
228245
{
@@ -241,6 +258,9 @@ public void onActivate()
241258
paused = false;
242259
waitingForChunksToLoad = false;
243260
elytraToggled = false;
261+
lastPos = mc.player.getPos();
262+
lastUnstuckPos = mc.player.getPos();
263+
stuckTimer = 0;
244264

245265
// I don't know any other way to fix this stupid shit
246266
if (bounce.get() && mc.player.getPos().multiply(1, 0, 1).length() >= 100)
@@ -280,6 +300,34 @@ public void onActivate()
280300
}
281301
}
282302

303+
private Vec3d lastPos;
304+
305+
@EventHandler
306+
private void onPlayerMove(PlayerMoveEvent event) {
307+
if (mc.player == null || event.type != MovementType.SELF || !enabled() || !motionYBoost.get() || !bounce.get()) return;
308+
309+
if (lastPos != null)
310+
{
311+
double speedBps = mc.player.getPos().subtract(lastPos).multiply(20, 0, 20).length();
312+
313+
Timer timer = Modules.get().get( Timer.class);
314+
if (timer.isActive()) {
315+
speedBps *= timer.getMultiplier();
316+
}
317+
318+
if (mc.player.isOnGround() && mc.player.isSprinting() && speedBps < speed.get())
319+
{
320+
if (speedBps > 20 || tunnelBounce.get())
321+
{
322+
event.movement = new Vec3d(event.movement.x, 0.0, event.movement.z);
323+
}
324+
mc.player.setVelocity(mc.player.getVelocity().x, 0.0, mc.player.getVelocity().z);
325+
}
326+
}
327+
328+
lastPos = mc.player.getPos();
329+
}
330+
283331
@Override
284332
public void onDeactivate()
285333
{
@@ -350,10 +398,21 @@ else if (tempPath != null)
350398
return;
351399
}
352400

401+
if (mc.player.squaredDistanceTo(lastUnstuckPos) < 25)
402+
{
403+
stuckTimer++;
404+
}
405+
else
406+
{
407+
stuckTimer = 0;
408+
lastUnstuckPos = mc.player.getPos();
409+
}
410+
353411
if (highwayObstaclePasser.get() && mc.player.getPos().length() > 100 && // > 100 check needed bc server sends queue coordinates when joining in first tick causing goal coordinates to be set to (0, 0)
354412
(mc.player.getY() < targetY.get() || mc.player.getY() > targetY.get() + 2 || mc.player.horizontalCollision) // collisions / out of highway
355413
|| (portalTrap != null && portalTrap.getSquaredDistance(mc.player.getBlockPos()) < portalAvoidDistance.get() * portalAvoidDistance.get()) // portal trap detection
356-
|| waitingForChunksToLoad) // waiting for chunks to load
414+
|| waitingForChunksToLoad // waiting for chunks to load
415+
|| stuckTimer > 30)
357416
{
358417
waitingForChunksToLoad = false;
359418
paused = true;
@@ -407,12 +466,6 @@ else if (tempPath != null)
407466

408467
if (!fakeFly.get())
409468
{
410-
double playerSpeed = Utils.getPlayerSpeed().multiply(1, 0, 1).length();
411-
if (motionYBoost.get() && mc.player.getVelocity().y > 0 && playerSpeed < speed.get())
412-
{
413-
mc.player.setVelocity(mc.player.getVelocity().x, 0.0, mc.player.getVelocity().z);
414-
}
415-
416469
if (mc.player.isOnGround())
417470
{
418471
mc.player.jump();
@@ -456,12 +509,6 @@ private void doGrimEflyStuff()
456509

457510
swapToItem(itemResult.slot());
458511

459-
double playerSpeed = Utils.getPlayerSpeed().multiply(1, 0, 1).length();
460-
if (bounce.get() && motionYBoost.get() && mc.player.getVelocity().y > 0 && playerSpeed < speed.get())
461-
{
462-
mc.player.setVelocity(mc.player.getVelocity().x, 0.0, mc.player.getVelocity().z);
463-
}
464-
465512
sendStartFlyingPacket();
466513

467514
if (bounce.get() && mc.player.isOnGround())
@@ -534,7 +581,7 @@ private void sendSwapPacket(Int2ObjectMap<ItemStack> changedSlots, int buttonNum
534581
@EventHandler
535582
private void onChunkData(ChunkDataEvent event)
536583
{
537-
if (!avoidPortalTraps.get()) return;
584+
if (!avoidPortalTraps.get() || !highwayObstaclePasser.get()) return;
538585
ChunkPos pos = event.chunk().getPos();
539586

540587
BlockPos centerPos = pos.getCenterAtY(targetY.get());

0 commit comments

Comments
 (0)