From 312b286f695abd1dd16a99bd526c0261c46ee74a Mon Sep 17 00:00:00 2001
From: xia-mc <2052472631@qq.com>
Date: Mon, 8 Jul 2024 18:42:24 +0800
Subject: [PATCH] fix scaffold add lowhop to tower remove double block from
 tower

---
 .../module/impl/world/Scaffold.java           |  2 +-
 .../module/impl/world/Tower.java              | 71 +++++++++----------
 2 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/src/main/java/keystrokesmod/module/impl/world/Scaffold.java b/src/main/java/keystrokesmod/module/impl/world/Scaffold.java
index 1346a5b0f..4ad5c883f 100644
--- a/src/main/java/keystrokesmod/module/impl/world/Scaffold.java
+++ b/src/main/java/keystrokesmod/module/impl/world/Scaffold.java
@@ -190,7 +190,7 @@ public void onPreUpdate(PreUpdateEvent e) { // place here
             }
         }
 
-        if (fastScaffold.getInput() == 7 && sameY$bridged != 0 && sameY$bridged % 2 == 0 && placeBlock != null && !Utils.jumpDown()) {
+        if (fastScaffold.getInput() == 7 && !Utils.jumpDown() && sameY$bridged != 0 && sameY$bridged % 2 == 0 && placeBlock != null && !Utils.jumpDown()) {
             List<BlockPos> possible = new ArrayList<>(Arrays.asList(
                     placeBlock.getBlockPos().west(),
                     placeBlock.getBlockPos().east(),
diff --git a/src/main/java/keystrokesmod/module/impl/world/Tower.java b/src/main/java/keystrokesmod/module/impl/world/Tower.java
index 59ffc5dc1..3dedc606a 100644
--- a/src/main/java/keystrokesmod/module/impl/world/Tower.java
+++ b/src/main/java/keystrokesmod/module/impl/world/Tower.java
@@ -40,8 +40,7 @@ public class Tower extends Module {
     private final ButtonSetting sprintJumpForward;
     private final ButtonSetting hypixelNoStrafe;
     private final SliderSetting hypixelOffGroundSpeed;
-    private final SliderSetting doubleBlockDelay;
-    private final ButtonSetting doubleBlock;
+    private final ButtonSetting lowHop;
     private int slowTicks;
     private boolean wasTowering;
     private int offGroundTicks = 0;
@@ -59,8 +58,7 @@ public Tower() {
         this.registerSetting(slowedTicks = new SliderSetting("Slowed ticks", 1, 0, 20, 1, mode0));
         this.registerSetting(hypixelOffGroundSpeed = new SliderSetting("Hypixel off ground speed", 0.5, 0.0, 1.0, 0.01, mode1));
         this.registerSetting(hypixelNoStrafe = new ButtonSetting("Hypixel no strafe", false, mode1));
-        this.registerSetting(doubleBlock = new ButtonSetting("Double block", false));
-        this.registerSetting(doubleBlockDelay = new SliderSetting("Double block delay", 100, 0, 2500, 10, "ms"));
+        this.registerSetting(lowHop = new ButtonSetting("Low hop", false, mode1));
         this.registerSetting(disableWhileCollided = new ButtonSetting("Disable while collided", false));
         this.registerSetting(disableWhileHurt = new ButtonSetting("Disable while hurt", false));
         this.registerSetting(sprintJumpForward = new ButtonSetting("Sprint jump forward", true));
@@ -79,27 +77,6 @@ public void onPreMotion(PreMotionEvent e) throws IllegalAccessException {
         if (canTower()) {
             wasTowering = true;
 
-            final boolean didDoubleBlock = doubleBlock.isToggled() && mc.thePlayer.motionX == 0 && mc.thePlayer.motionZ == 0;
-            if (didDoubleBlock) {
-                if (scaffold.placeBlock != null) {
-                    BlockPos groundBlock = scaffold.placeBlock.getBlockPos().add(1, -1, 0);
-                    if (BlockUtils.isFullBlock(mc.theWorld.getBlockState(groundBlock))) {
-                        toweredBlock = groundBlock.up();
-                    } else {
-                        toweredBlock = null;
-                    }
-                    if (toweredBlock != null) {
-                        BlockIn.getPlaceSide(toweredBlock).ifPresent(placeSide ->
-                                Raven.getExecutor().schedule(() ->
-                                                scaffold.place(
-                                                        new MovingObjectPosition(placeSide.getRight().toVec3(), placeSide.getMiddle(), placeSide.getLeft())
-                                                        , true)
-                                        , (long) doubleBlockDelay.getInput(), TimeUnit.MILLISECONDS)
-                        );
-                    }
-                }
-            }
-
             switch ((int) mode.getInput()) {
                 case 0:
                     Utils.setSpeed(Math.max((diagonal() ? diagonalSpeed.getInput() : speed.getInput()) * 0.1 - 0.25, 0));
@@ -109,23 +86,20 @@ public void onPreMotion(PreMotionEvent e) throws IllegalAccessException {
                     Reflection.jumpTicks.set(mc.thePlayer, 0);
                     e.setSprinting(false);
 
-                    if (!didDoubleBlock) {
-                        toweredBlock = null;
-                        double moveSpeed = e.isOnGround() ? speed.getInput() : hypixelOffGroundSpeed.getInput();
-                        if (hypixelNoStrafe.isToggled()) {
-                            if (Math.abs(mc.thePlayer.motionX) >= Math.abs(mc.thePlayer.motionZ)) {
-                                mc.thePlayer.motionX *= moveSpeed;
-                                mc.thePlayer.motionZ = 0;
-                            } else {
-                                mc.thePlayer.motionZ *= moveSpeed;
-                                mc.thePlayer.motionX = 0;
-                            }
-                        } else {
+                    toweredBlock = null;
+                    double moveSpeed = e.isOnGround() ? speed.getInput() : hypixelOffGroundSpeed.getInput();
+                    if (hypixelNoStrafe.isToggled()) {
+                        if (Math.abs(mc.thePlayer.motionX) >= Math.abs(mc.thePlayer.motionZ)) {
                             mc.thePlayer.motionX *= moveSpeed;
+                            mc.thePlayer.motionZ = 0;
+                        } else {
                             mc.thePlayer.motionZ *= moveSpeed;
+                            mc.thePlayer.motionX = 0;
                         }
+                    } else {
+                        mc.thePlayer.motionX *= moveSpeed;
+                        mc.thePlayer.motionZ *= moveSpeed;
                     }
-                    break;
                 case 2:
                     if (mc.thePlayer.onGround)
                         mc.thePlayer.motionY = 0.42F;
@@ -173,6 +147,27 @@ public void onPreUpdate(PreUpdateEvent event) {
         } else {
             offGroundTicks++;
         }
+
+        if (canTower() && lowHop.isToggled() && Utils.isMoving()) {
+            switch (offGroundTicks) {
+                case 0:
+                    mc.thePlayer.motionY = 0.4196;
+                    break;
+                case 3:
+                case 4:
+                    mc.thePlayer.motionY = 0;
+                    break;
+                case 5:
+                    mc.thePlayer.motionY = 0.4191;
+                    break;
+                case 6:
+                    mc.thePlayer.motionY = 0.3275;
+                    break;
+                case 11:
+                    mc.thePlayer.motionY = -0.5;
+                    break;
+            }
+        }
     }
 
     private void reset() {