Skip to content

Commit

Permalink
improve GrimACBoat fly
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-mc committed Jul 10, 2024
1 parent 1201e58 commit 3c22630
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
43 changes: 26 additions & 17 deletions src/main/java/keystrokesmod/module/impl/movement/Fly.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import keystrokesmod.module.setting.impl.ModeSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
import keystrokesmod.module.setting.utils.ModeOnly;
import keystrokesmod.script.classes.Vec3;
import keystrokesmod.utility.MoveUtil;
import keystrokesmod.utility.PacketUtils;
import keystrokesmod.utility.render.RenderUtils;
import keystrokesmod.utility.Utils;
import net.minecraft.block.BlockAir;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
Expand All @@ -29,7 +31,6 @@ public class Fly extends Module {
private final SliderSetting verticalSpeed;
private final SliderSetting maxBalance;
private final ButtonSetting autoDisable;
private final SliderSetting motionMultiplier;
private final ButtonSetting showBPS;
private final ButtonSetting stopMotion;
private boolean d;
Expand All @@ -42,7 +43,6 @@ public class Fly extends Module {
private long startTime = -1;
private Timer.BalanceState balanceState = Timer.BalanceState.NONE;
private long lastReport = -1;
private boolean lastOnBoat = false;

public Fly() {
super("Fly", category.movement);
Expand All @@ -53,7 +53,6 @@ public Fly() {
this.registerSetting(verticalSpeed = new SliderSetting("Vertical speed", 2.0, 0.0, 9.0, 0.1, canChangeSpeed));
this.registerSetting(maxBalance = new SliderSetting("Max balance", 6000, 3000, 30000, 1000, "ms", balanceMode));
this.registerSetting(autoDisable = new ButtonSetting("Auto disable", true, balanceMode));
this.registerSetting(motionMultiplier = new SliderSetting("Motion multiplier", 1.0, 0.8, 1.2, 0.05, new ModeOnly(mode, 6)));
this.registerSetting(showBPS = new ButtonSetting("Show BPS", false));
this.registerSetting(stopMotion = new ButtonSetting("Stop motion", false));
}
Expand Down Expand Up @@ -180,20 +179,31 @@ else if (Utils.jumpDown()) {
setSpeed(0.4 * horizontalSpeed.getInput());
break;
case 6:
boolean curOnBoat = mc.thePlayer.isRiding() && mc.thePlayer.ridingEntity instanceof EntityBoat;

mc.thePlayer.motionX *= motionMultiplier.getInput();
mc.thePlayer.motionY *= motionMultiplier.getInput();
mc.thePlayer.motionZ *= motionMultiplier.getInput();

if (lastOnBoat && !curOnBoat) {
mc.thePlayer.setSneaking(false);
((KeyBindingAccessor) mc.gameSettings.keyBindSneak).setPressed(false);
MoveUtil.strafe(horizontalSpeed.getInput());
mc.thePlayer.motionY = verticalSpeed.getInput();
/*
* @see ac.grim.grimac.predictionengine.UncertaintyHandler#hasHardCollision
* SUPER⭐GrimAC⭐TIME
*/
for (Entity entity : mc.theWorld.loadedEntityList) {
AxisAlignedBB playerBox = mc.thePlayer.getEntityBoundingBox();
AxisAlignedBB grimACBox = playerBox.expand(1, 1, 1);
if (entity instanceof EntityBoat) {
AxisAlignedBB boatBox = entity.getEntityBoundingBox();
if (boatBox.intersectsWith(grimACBox) && !(boatBox.intersectsWith(playerBox))) {
if (Utils.jumpDown()) {
mc.thePlayer.motionY = 0.5 * verticalSpeed.getInput();
} else if (mc.thePlayer.isSneaking()) {
mc.thePlayer.motionY = -0.5 * verticalSpeed.getInput();
} else {
mc.thePlayer.motionY = 0.0;
}
if (MoveUtil.isMoving())
MoveUtil.strafe(horizontalSpeed.getInput());
else
MoveUtil.stop();
}
}
}

lastOnBoat = curOnBoat;
break;
}

}
Expand Down Expand Up @@ -227,7 +237,6 @@ public void onDisable() {
if ((int) mode.getInput() == 5) {
MoveUtil.stop();
}
lastOnBoat = false;
}

private void balance$reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onPreInput(PrePlayerInputEvent input) {
return;
}

float current = RotationUtils.normalize(mc.thePlayer.rotationYaw);
float current = mc.thePlayer.rotationYaw;
float toTarget = RotationUtils.getRotations(KillAura.target)[0];
float diff = toTarget - current;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ public void onPreMotion(MoveInputEvent event) {
lastRotationPitch = rotationPitch;
switch ((int) smoothBack.getInput()) {
case 0:
rotationYaw = RotationUtils.normalize(mc.thePlayer.rotationYaw);
rotationYaw = mc.thePlayer.rotationYaw;
rotationPitch = mc.thePlayer.rotationPitch;
break;
case 1:
rotationYaw = AimSimulator.rotMove(RotationUtils.normalize(mc.thePlayer.rotationYaw), getRotationYaw(), (float) aimSpeed.getInput());
rotationYaw = AimSimulator.rotMove(mc.thePlayer.rotationYaw, getRotationYaw(), (float) aimSpeed.getInput());
rotationPitch = AimSimulator.rotMove(mc.thePlayer.rotationPitch, getRotationPitch(), (float) aimSpeed.getInput());
break;
}
}

if (getRotationYaw() == RotationUtils.normalize(mc.thePlayer.rotationYaw)) rotationYaw = null;
if (AimSimulator.yawEquals(getRotationYaw(), mc.thePlayer.rotationYaw)) rotationYaw = null;
if (getRotationPitch() == mc.thePlayer.rotationPitch) rotationPitch = null;

RotationEvent rotationEvent = new RotationEvent(getRotationYaw(), getRotationPitch());
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/keystrokesmod/utility/AimSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ public static float rotMoveNoRandom(float target, float current, float diff) {
}
}
}

public static boolean yawEquals(float yaw1, float yaw2) {
return RotationUtils.normalize(yaw1) == RotationUtils.normalize(yaw2);
}
}

0 comments on commit 3c22630

Please sign in to comment.