Skip to content

Commit

Permalink
Add 'swingSpeedWhileBlocking' to Animations
Browse files Browse the repository at this point in the history
Improve HypixelGroundSpeed
Try to fix scaffold sprint
  • Loading branch information
xia-mc committed Dec 4, 2024
1 parent f6820d9 commit b309f5c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 25 deletions.
9 changes: 4 additions & 5 deletions src/main/java/keystrokesmod/module/impl/movement/Sprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public Sprint() {

public static boolean omni() {
final SprintEvent event = new SprintEvent(
MoveUtil.isMoving(),
omni || ModuleManager.sprint != null && ModuleManager.sprint.isEnabled() && ModuleManager.sprint.mode.getInput() == 1
MoveUtil.canSprint(true),
omni || (ModuleManager.sprint != null && ModuleManager.sprint.isEnabled() && ModuleManager.sprint.mode.getInput() == 1)
);

return event.isSprint() && event.isOmni();
Expand All @@ -48,10 +48,9 @@ public static boolean stopSprint() {
public void p(PlayerTickEvent e) {
if (Utils.nullCheck() && mc.inGameHasFocus) {

if(ModuleManager.scaffold.isEnabled() && disableWhileScaffold.isToggled()) {
if (ModuleManager.scaffold.isEnabled() && disableWhileScaffold.isToggled()) {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), false);
}
else {
} else {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public class HypixelSpeed extends SubMode<Speed> {
private final ModeValue mode;
private final ButtonSetting strafe;
private final SliderSetting slowdown;
private final SliderSetting minAngle;
private final ButtonSetting fullStrafe;

Expand All @@ -31,6 +32,7 @@ public HypixelSpeed(String name, @NotNull Speed parent) {
.add(new HypixelLowHopSpeed("LowHop", this))
);
this.registerSetting(strafe = new ButtonSetting("Strafe", false));
this.registerSetting(slowdown = new SliderSetting("Slowdown", 1, 1, 2, 0.01));
this.registerSetting(minAngle = new SliderSetting("Min angle", 30, 15, 90, 15, strafe::isToggled));
this.registerSetting(fullStrafe = new ButtonSetting("Full strafe", false, strafe::isToggled));
}
Expand All @@ -39,16 +41,18 @@ public HypixelSpeed(String name, @NotNull Speed parent) {
public void onPreUpdate(PreUpdateEvent event) {
if (strafe.isToggled() && canStrafe()) {
if (parent.offGroundTicks == 9) {
MoveUtil.strafe(0.2);
MoveUtil.strafe(Math.min(0.2 * slowdown.getInput(), MoveUtil.speed()));
mc.thePlayer.motionY += 0.1;
} else if (parent.offGroundTicks == 1) {
MoveUtil.strafe();
} else {
MoveUtil.strafe(0.11);
MoveUtil.strafe(Math.min(0.11 * slowdown.getInput(), MoveUtil.speed()));
}
}
}

private boolean canStrafe() {
if (mc.thePlayer.onGround)
if (mc.thePlayer.onGround || !MoveUtil.isMoving())
return false;
final double curAngle = Move.fromMovement(mc.thePlayer.moveForward, mc.thePlayer.moveStrafing).getDeltaYaw()
+ TargetStrafe.getMovementYaw();
Expand All @@ -58,8 +62,8 @@ private boolean canStrafe() {
lastAngle = curAngle;

if (fullStrafe.isToggled())
return parent.offGroundTicks >= 4 && parent.offGroundTicks <= 9;
return parent.offGroundTicks == 4 || parent.offGroundTicks == 9;
return parent.offGroundTicks == 1 || (parent.offGroundTicks >= 4 && parent.offGroundTicks <= 9);
return parent.offGroundTicks == 1 || parent.offGroundTicks == 4 || parent.offGroundTicks == 9;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
package keystrokesmod.module.impl.movement.speed.hypixel;

import keystrokesmod.event.PrePlayerInputEvent;
import keystrokesmod.event.PreMotionEvent;
import keystrokesmod.event.SendPacketEvent;
import keystrokesmod.module.impl.movement.speed.HypixelSpeed;
import keystrokesmod.module.impl.player.blink.NormalBlink;
import keystrokesmod.module.setting.impl.SubMode;
import keystrokesmod.utility.MoveUtil;
import keystrokesmod.utility.Utils;
import net.minecraft.network.play.client.C0FPacketConfirmTransaction;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;

public class HypixelGroundSpeed extends SubMode<HypixelSpeed> {
private final NormalBlink blink = new NormalBlink("Blink", this) {
@Override
public void onSendPacket(@NotNull SendPacketEvent e) {
if (e.getPacket() instanceof C0FPacketConfirmTransaction)
return;
super.onSendPacket(e);
}
};

public HypixelGroundSpeed(String name, @NotNull HypixelSpeed parent) {
super(name, parent);
}

@SubscribeEvent
public void onPrePlayerInput(PrePlayerInputEvent event) {
if (!Utils.nullCheck() || parent.parent.noAction()) return;
if (mc.thePlayer.onGround && MoveUtil.isMoving() && mc.currentScreen == null) {
event.setSpeed(MoveUtil.getAllowedHorizontalDistance() - Math.random() / 100);
public void onDisable() {
blink.disable();

mc.thePlayer.motionX *= .8;
mc.thePlayer.motionZ *= .8;
}

@SubscribeEvent(priority = EventPriority.HIGH)
public void onPreUpdate(PreMotionEvent event) {
if (mc.thePlayer.onGround) {
mc.thePlayer.motionX *= 1.114 - MoveUtil.getSpeedEffect() * .01 - Math.random() * 1E-4;
mc.thePlayer.motionZ *= 1.114 - MoveUtil.getSpeedEffect() * .01 - Math.random() * 1E-4;
}

if (mc.thePlayer.onGround && mc.thePlayer.ticksExisted % 2 == 0) {
blink.enable();
} else {
blink.disable();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package keystrokesmod.module.impl.movement.speed.hypixel.lowhop;

import keystrokesmod.event.PrePlayerInputEvent;
import keystrokesmod.event.PreUpdateEvent;
import keystrokesmod.module.impl.movement.speed.hypixel.HypixelLowHopSpeed;
import keystrokesmod.module.setting.impl.SubMode;
import keystrokesmod.utility.MoveUtil;
Expand All @@ -14,7 +14,7 @@ public HypixelLowHopPredictSpeed(String name, @NotNull HypixelLowHopSpeed parent
}

@SubscribeEvent
public void onPrePlayerInput(PrePlayerInputEvent event) {
public void onPreUpdate(PreUpdateEvent event) {
if (!MoveUtil.isMoving() || parent.parent.parent.noAction()) return;
if (parent.parent.parent.offGroundTicks == 0) {
if (!Utils.jumpDown()) {
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/keystrokesmod/module/impl/render/Animations.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public class Animations extends Module {
private final SliderSetting y = new SliderSetting("Y", 0, -1, 1, 0.05);
private final SliderSetting z = new SliderSetting("Z", 0, -1, 1, 0.05);
private final SliderSetting swingSpeed = new SliderSetting("Swing speed", 0, -200, 50, 5);
private final SliderSetting swingSpeedWhileBlocking = new SliderSetting("Swing speed while blocking", 0, -200, 50, 5);

private int swing;

public Animations() {
super("Animations", category.render);
this.registerSetting(blockAnimation, swingAnimation, otherAnimation, swingWhileDigging, clientSide, fakeSlotReset, x, y, z, swingSpeed);
this.registerSetting(blockAnimation, swingAnimation, otherAnimation, swingWhileDigging, clientSide, fakeSlotReset, x, y, z, swingSpeed, swingSpeedWhileBlocking);
}

@SubscribeEvent
Expand All @@ -56,13 +57,13 @@ public void onReceivePacket(ReceivePacketEvent event) {
if (Utils.nullCheck()
&& fakeSlotReset.isToggled()
&& event.getPacket() instanceof S0BPacketAnimation
&& SlotHandler.getHeldItem() != null
&& SlotHandler.getCurrentSlot() == mc.thePlayer.inventory.currentItem
&& !SlotHandler.isSilentSlot()
&& KillAura.target != null
) {
final S0BPacketAnimation packet = (S0BPacketAnimation) event.getPacket();
if (packet.getAnimationType() == 1 && packet.getEntityID() == KillAura.target.getEntityId()) {
mc.getItemRenderer().resetEquippedProgress();
Utils.sendMessage("reset.");
}
}
}
Expand Down Expand Up @@ -280,7 +281,11 @@ public void onPreMotion(PreMotionEvent event) {

@SubscribeEvent
public void onSwingAnimation(@NotNull SwingAnimationEvent event) {
event.setAnimationEnd(event.getAnimationEnd() * (int) ((-swingSpeed.getInput() / 100) + 1));
if (mc.thePlayer.isUsingItem()) {
event.setAnimationEnd((int) (event.getAnimationEnd() * ((-swingSpeedWhileBlocking.getInput() / 100) + 1)));
} else {
event.setAnimationEnd((int) (event.getAnimationEnd() * ((-swingSpeed.getInput() / 100) + 1)));
}
}

private void translate(double x, double y, double z) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/keystrokesmod/module/impl/world/Scaffold.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ public static boolean sprint() {
return false;
}

@SubscribeEvent
public void onSprint(SprintEvent event) {
if (!sprint()) {
event.setSprint(false);
}
}

public static int getSlot() {
int slot = -1;
int highestStack = -1;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/keystrokesmod/utility/MoveUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,17 @@ public static int getSpeedEffect() {
return 0;
}

public static int getJumpEffect() {
if (mc.thePlayer.isPotionActive(Potion.jump))
return mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1;
return 0;
}

/**
* Checks if the player is moving
*
* @return player moving
*/
@Contract(pure = true)
public static boolean isMoving() {
return isMoving(mc.thePlayer);
}
Expand All @@ -233,7 +238,6 @@ public static boolean isMoving(@NotNull EntityLivingBase entity) {
return entity.moveForward != 0 || entity.moveStrafing != 0;
}

@Contract(pure = true)
public static boolean isRealMoving() {
return mc.thePlayer.motionX != 0 || (mc.thePlayer.motionY != 0 && !mc.thePlayer.onGround) || mc.thePlayer.motionZ != 0;
}
Expand Down

0 comments on commit b309f5c

Please sign in to comment.