Skip to content

Commit

Permalink
Improved ElytraFly Recast mode (MeteorDevelopment#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
supakeks authored Sep 2, 2023
1 parent 0b32e28 commit 7d4645a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFlightModes;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Recast;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Bounce;
import meteordevelopment.meteorclient.systems.modules.player.OffhandCrash;
import meteordevelopment.meteorclient.systems.modules.player.PotionSpoof;
import meteordevelopment.meteorclient.systems.modules.render.HandView;
Expand Down Expand Up @@ -117,8 +117,8 @@ private boolean isFallFlyingHook(boolean original) {
public void recastOnLand(CallbackInfoReturnable<Boolean> cir) {
boolean elytra = cir.getReturnValue();
ElytraFly elytraFly = Modules.get().get(ElytraFly.class);
if (previousElytra && !elytra && elytraFly.isActive() && elytraFly.flightMode.get() == ElytraFlightModes.Recast) {
cir.setReturnValue(Recast.recastElytra(mc.player));
if (previousElytra && !elytra && elytraFly.isActive() && elytraFly.flightMode.get() == ElytraFlightModes.Bounce) {
cir.setReturnValue(Bounce.recastElytra(mc.player));
}
previousElytra = elytra;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void onTick() {
}
}

public void onPreTick() {
}

public void onPacketSend(PacketEvent.Send event) {
}

Expand Down Expand Up @@ -106,7 +109,7 @@ public void autoTakeoff() {
public void handleAutopilot() {
if (!mc.player.isFallFlying()) return;

if (elytraFly.autoPilot.get() && mc.player.getY() > elytraFly.autoPilotMinimumHeight.get() && elytraFly.flightMode.get() != ElytraFlightModes.Recast) {
if (elytraFly.autoPilot.get() && mc.player.getY() > elytraFly.autoPilotMinimumHeight.get() && elytraFly.flightMode.get() != ElytraFlightModes.Bounce) {
mc.options.forwardKey.setPressed(true);
lastForwardPressed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public enum ElytraFlightModes {
Vanilla,
Packet,
Pitch40,
Recast
Bounce
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Packet;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Pitch40;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Recast;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Bounce;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Vanilla;
import meteordevelopment.meteorclient.systems.modules.player.ChestSwap;
import meteordevelopment.meteorclient.systems.modules.render.Freecam;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ElytraItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
Expand Down Expand Up @@ -60,7 +54,7 @@ public class ElytraFly extends Module {
.name("auto-take-off")
.description("Automatically takes off when you hold jump without needing to double jump.")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -69,7 +63,7 @@ public class ElytraFly extends Module {
.description("Controls how fast will you go down naturally.")
.defaultValue(0.01)
.min(0)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -78,7 +72,7 @@ public class ElytraFly extends Module {
.description("How fast you go forward and backward.")
.defaultValue(1)
.min(0)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -87,14 +81,14 @@ public class ElytraFly extends Module {
.description("How fast you go up and down.")
.defaultValue(1)
.min(0)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

public final Setting<Boolean> acceleration = sgGeneral.add(new BoolSetting.Builder()
.name("acceleration")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -103,23 +97,23 @@ public class ElytraFly extends Module {
.min(0.1)
.max(5)
.defaultValue(1)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

public final Setting<Double> accelerationMin = sgGeneral.add(new DoubleSetting.Builder()
.name("acceleration-start")
.min(0.1)
.defaultValue(0)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

public final Setting<Boolean> stopInWater = sgGeneral.add(new BoolSetting.Builder()
.name("stop-in-water")
.description("Stops flying in water.")
.defaultValue(true)
.visible(() -> flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -134,15 +128,15 @@ public class ElytraFly extends Module {
.name("auto-hover")
.description("Automatically hover .3 blocks off ground when holding shift.")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

public final Setting<Boolean> noCrash = sgGeneral.add(new BoolSetting.Builder()
.name("no-crash")
.description("Stops you from going into walls.")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -152,15 +146,15 @@ public class ElytraFly extends Module {
.defaultValue(5)
.range(1, 15)
.sliderMin(1)
.visible(noCrash::get)
.visible(() -> noCrash.get() && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

private final Setting<Boolean> instaDrop = sgGeneral.add(new BoolSetting.Builder()
.name("insta-drop")
.description("Makes you drop out of flight instantly.")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand Down Expand Up @@ -198,7 +192,7 @@ public class ElytraFly extends Module {
.name("auto-jump")
.description("Automatically jumps for you.")
.defaultValue(true)
.visible(() -> flightMode.get() == ElytraFlightModes.Recast)
.visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -208,25 +202,33 @@ public class ElytraFly extends Module {
.defaultValue(85)
.range(0, 90)
.sliderRange(0, 90)
.visible(() -> flightMode.get() == ElytraFlightModes.Recast)
.visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
.build()
);

public final Setting<Boolean> restart = sgGeneral.add(new BoolSetting.Builder()
.name("restart")
.description("Restarts flying with the elytra when rubberbanding.")
.defaultValue(true)
.visible(() -> flightMode.get() == ElytraFlightModes.Recast)
.visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
.build()
);

public final Setting<Integer> restartDelay = sgGeneral.add(new IntSetting.Builder()
.name("restart-delay")
.description("How many ticks to wait before restarting the elytra again after rubberbanding.")
.defaultValue(7)
.range(0, 20)
.min(0)
.sliderRange(0, 20)
.visible(() -> flightMode.get() == ElytraFlightModes.Recast && restart.get())
.visible(() -> flightMode.get() == ElytraFlightModes.Bounce && restart.get())
.build()
);

public final Setting<Boolean> sprint = sgGeneral.add(new BoolSetting.Builder()
.name("sprint")
.description("Sprints all the time. If turned off, it will only sprint when the player is touching the ground.")
.defaultValue(true)
.visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
.build()
);

Expand Down Expand Up @@ -279,15 +281,15 @@ public class ElytraFly extends Module {
.name("auto-pilot")
.description("Moves forward while elytra flying.")
.defaultValue(false)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

public final Setting<Boolean> useFireworks = sgAutopilot.add(new BoolSetting.Builder()
.name("use-fireworks")
.description("Uses firework rockets every second of your choice.")
.defaultValue(false)
.visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -297,7 +299,7 @@ public class ElytraFly extends Module {
.min(1)
.defaultValue(8)
.sliderMax(20)
.visible(() -> useFireworks.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> useFireworks.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -307,7 +309,7 @@ public class ElytraFly extends Module {
.defaultValue(120)
.min(-128)
.sliderMax(260)
.visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Recast)
.visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
.build()
);

Expand All @@ -321,7 +323,7 @@ public ElytraFly() {
public void onActivate() {
currentMode.onActivate();
if ((chestSwap.get() == ChestSwapMode.Always || chestSwap.get() == ChestSwapMode.WaitForGround)
&& mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
&& mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
Modules.get().get(ChestSwap.class).swap();
}
}
Expand Down Expand Up @@ -351,7 +353,7 @@ private void onPlayerMove(PlayerMoveEvent event) {

if (mc.player.isFallFlying()) {

if (flightMode.get() != ElytraFlightModes.Recast) {
if (flightMode.get() != ElytraFlightModes.Bounce) {
currentMode.velX = 0;
currentMode.velY = event.movement.y;
currentMode.velZ = 0;
Expand All @@ -376,21 +378,21 @@ private void onPlayerMove(PlayerMoveEvent event) {
int chunkZ = (int) ((mc.player.getZ() + currentMode.velZ) / 16);
if (dontGoIntoUnloadedChunks.get()) {
if (mc.world.getChunkManager().isChunkLoaded(chunkX, chunkZ)) {
if (flightMode.get() != ElytraFlightModes.Recast) ((IVec3d) event.movement).set(currentMode.velX, currentMode.velY, currentMode.velZ);
if (flightMode.get() != ElytraFlightModes.Bounce) ((IVec3d) event.movement).set(currentMode.velX, currentMode.velY, currentMode.velZ);
} else {
((IVec3d) event.movement).set(0, currentMode.velY, 0);
}
} else if (flightMode.get() != ElytraFlightModes.Recast) ((IVec3d) event.movement).set(currentMode.velX, currentMode.velY, currentMode.velZ);
} else if (flightMode.get() != ElytraFlightModes.Bounce) ((IVec3d) event.movement).set(currentMode.velX, currentMode.velY, currentMode.velZ);

if (flightMode.get() != ElytraFlightModes.Recast) currentMode.onPlayerMove();
if (flightMode.get() != ElytraFlightModes.Bounce) currentMode.onPlayerMove();
} else {
if (currentMode.lastForwardPressed && flightMode.get() != ElytraFlightModes.Recast) {
if (currentMode.lastForwardPressed && flightMode.get() != ElytraFlightModes.Bounce) {
mc.options.forwardKey.setPressed(false);
currentMode.lastForwardPressed = false;
}
}

if (noCrash.get() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Recast) {
if (noCrash.get() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Bounce) {
Vec3d lookAheadPos = mc.player.getPos().add(mc.player.getVelocity().normalize().multiply(crashLookAhead.get()));
RaycastContext raycastContext = new RaycastContext(mc.player.getPos(), new Vec3d(lookAheadPos.getX(), mc.player.getY(), lookAheadPos.getZ()), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player);
BlockHitResult hitResult = mc.world.raycast(raycastContext);
Expand All @@ -399,7 +401,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
}
}

if (autoHover.get() && mc.player.input.sneaking && !Modules.get().get(Freecam.class).isActive() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Recast) {
if (autoHover.get() && mc.player.input.sneaking && !Modules.get().get(Freecam.class).isActive() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Bounce) {
BlockState underState = mc.world.getBlockState(mc.player.getBlockPos().down());
Block under = underState.getBlock();
BlockState under2State = mc.world.getBlockState(mc.player.getBlockPos().down().down());
Expand Down Expand Up @@ -437,6 +439,11 @@ private void onTick(TickEvent.Post event) {
currentMode.onTick();
}

@EventHandler
private void onPreTick(TickEvent.Pre event) {
currentMode.onPreTick();
}

@EventHandler
private void onPacketSend(PacketEvent.Send event) {
currentMode.onPacketSend(event);
Expand All @@ -455,7 +462,7 @@ private void onModeChanged(ElytraFlightModes mode) {
currentMode = new Pitch40();
autoPilot.set(false); // Pitch 40 is an autopilot of its own
}
case Recast -> currentMode = new Recast();
case Bounce -> currentMode = new Bounce();
}
}

Expand Down
Loading

0 comments on commit 7d4645a

Please sign in to comment.