Skip to content

Commit 7c4fbc8

Browse files
committed
No crash for Elytra Fly+
1 parent 8665ec4 commit 7c4fbc8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/java/nekiplay/meteorplus/features/modules/movement/elytrafly/ElytraFlyPlus.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
44
import meteordevelopment.meteorclient.events.packets.PacketEvent;
55
import meteordevelopment.meteorclient.events.world.TickEvent;
6+
import meteordevelopment.meteorclient.mixininterface.IVec3d;
67
import meteordevelopment.meteorclient.settings.*;
78
import meteordevelopment.meteorclient.systems.modules.Categories;
89
import meteordevelopment.meteorclient.systems.modules.Module;
910
import meteordevelopment.orbit.EventHandler;
1011
import meteordevelopment.starscript.compiler.Expr;
1112
import nekiplay.meteorplus.features.modules.movement.elytrafly.modes.Control;
1213
import nekiplay.meteorplus.features.modules.movement.elytrafly.modes.Wasp;
14+
import net.minecraft.util.hit.BlockHitResult;
15+
import net.minecraft.util.hit.HitResult;
16+
import net.minecraft.util.math.Vec3d;
17+
import net.minecraft.world.RaycastContext;
1318

1419
public class ElytraFlyPlus extends Module {
1520
private final SettingGroup sgGeneral = settings.getDefaultGroup();
@@ -123,6 +128,23 @@ public class ElytraFlyPlus extends Module {
123128
.build()
124129
);
125130

131+
public final Setting<Boolean> noCrash = sgGeneral.add(new BoolSetting.Builder()
132+
.name("no-crash")
133+
.description("Stops you from going into walls.")
134+
.defaultValue(false)
135+
.build()
136+
);
137+
138+
public final Setting<Integer> crashLookAhead = sgGeneral.add(new IntSetting.Builder()
139+
.name("crash-look-ahead")
140+
.description("Distance to look ahead when flying.")
141+
.defaultValue(5)
142+
.range(1, 15)
143+
.sliderMin(1)
144+
.visible(noCrash::get)
145+
.build()
146+
);
147+
126148
private ElytraFlyMode currentMode = new Control();
127149

128150
public ElytraFlyPlus() {
@@ -142,6 +164,15 @@ public void onDeactivate() {
142164
@EventHandler
143165
private void onPlayerMove(PlayerMoveEvent event) {
144166
currentMode.onPlayerMove(event);
167+
168+
if (noCrash.get() && mc.player.isGliding()) {
169+
Vec3d lookAheadPos = mc.player.getPos().add(mc.player.getVelocity().normalize().multiply(crashLookAhead.get()));
170+
RaycastContext raycastContext = new RaycastContext(mc.player.getPos(), new Vec3d(lookAheadPos.getX(), mc.player.getY(), lookAheadPos.getZ()), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player);
171+
BlockHitResult hitResult = mc.world.raycast(raycastContext);
172+
if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
173+
((IVec3d) event.movement).meteor$set(0, currentMode.velY, 0);
174+
}
175+
}
145176
}
146177

147178
@EventHandler

0 commit comments

Comments
 (0)