From fe3a4a0a1c4b875331a7f5129b7f26cad950b92d Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Mon, 4 Apr 2022 17:50:36 +0100 Subject: [PATCH 01/12] Add Boost to Speed, settings edited on other modes to be better compliant with NCP --- .../client/module/modules/movement/Speed.kt | 82 +++++++++++++++++-- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index f7eafbe68..b0e2e736e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -1,11 +1,12 @@ package com.lambda.client.module.modules.movement import com.lambda.client.event.SafeClientEvent +import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer -import com.lambda.client.mixin.extension.isInWeb +import com.lambda.client.mixin.extension.* import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.AutoEat @@ -23,8 +24,10 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.settings.KeyBinding +import net.minecraft.network.play.client.CPacketPlayer import net.minecraftforge.fml.common.gameevent.TickEvent import java.lang.Double.max +import java.lang.Double.min import kotlin.math.cos import kotlin.math.sin @@ -38,7 +41,7 @@ object Speed : Module( val mode by setting("Mode", SpeedMode.STRAFE) // strafe settings - private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.029f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE }) + private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE }) private val strafeTimerBoost by setting("Timer Boost", true, { mode == SpeedMode.STRAFE }) private val strafeAutoJump by setting("Auto Jump", true, { mode == SpeedMode.STRAFE }) private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE }) @@ -46,11 +49,14 @@ object Speed : Module( // onGround settings private val onGroundTimer by setting("Timer", true, { mode == SpeedMode.ONGROUND }) - private val onGroundTimerSpeed by setting("Timer Speed", 1.29f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer }) + private val onGroundTimerSpeed by setting("Timer Speed", 1.088f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer }) private val onGroundSpeed by setting("Speed", 1.31f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND }) private val onGroundSprint by setting("Sprint", true, { mode == SpeedMode.ONGROUND }) private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND }) + // boost settings + private val boostSpeed by setting("Boost Speed", .61, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST}) + // Strafe Mode private var jumpTicks = 0 private val strafeTimer = TickTimer(TimeUnit.TICKS) @@ -60,8 +66,10 @@ object Speed : Module( private var currentMode = mode + private var spoofUp = true + enum class SpeedMode { - STRAFE, ONGROUND + STRAFE, ONGROUND, BOOST } init { @@ -105,13 +113,49 @@ object Speed : Module( if (shouldOnGround()) onGround() else resetTimer() } + SpeedMode.BOOST -> { + + handleBoost(it) + + } } } + + safeListener { + + if (mode == SpeedMode.BOOST) { + + if (it.packet is CPacketPlayer) { + + if (it.packet.playerMoving && spoofUp) { + + it.packet.playerIsOnGround = false + + it.packet.playerY = + ( + if ( + world.collidesWithAnyBlock( + player.entityBoundingBox + .offset(it.packet.playerX, it.packet.playerY, it.packet.playerZ) + .offset(0.0,.42,0.0)) + ) + .2 + else + .42 + ) + player.posY + } + } + + } + + } + } private fun SafeClientEvent.strafe() { player.jumpMovementFactor = strafeAirSpeedBoost - if (strafeTimerBoost) modifyTimer(45.87155914306640625f) + // slightly slower timer speed bypasses better (1.088) + if (strafeTimerBoost) modifyTimer(45.955883f) if ((Step.isDisabled || !player.collidedHorizontally) && strafeAutoJump) jump() strafeTimer.reset() @@ -168,4 +212,30 @@ object Speed : Module( jumpTicks-- } -} \ No newline at end of file + + private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { + + spoofUp = !spoofUp && player.onGround + + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f) { + modifyTimer(50f) + spoofUp = false + return + } + + modifyTimer(45.955883f) + + val speed = if (spoofUp) boostSpeed else .2873 + + val yaw = calcMoveYaw() + event.x = -sin(yaw) * speed + if (spoofUp) { + event.y = min(0.0, event.y) + } else if (player.movementInput.jump) { + jump() + } + event.z = cos(yaw) * speed + + } + +} From 30b378993dcfd4867db31afa0a25baca42486431 Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Mon, 4 Apr 2022 19:32:54 +0100 Subject: [PATCH 02/12] Fix Boost speed, now fully functional --- .../client/module/modules/movement/Speed.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index b0e2e736e..ad4edf872 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -55,7 +55,7 @@ object Speed : Module( private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND }) // boost settings - private val boostSpeed by setting("Boost Speed", .61, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST}) + private val boostSpeed by setting("Boost Speed", .388, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST}) // Strafe Mode private var jumpTicks = 0 @@ -131,18 +131,18 @@ object Speed : Module( it.packet.playerIsOnGround = false - it.packet.playerY = + val pos = ( if ( - world.collidesWithAnyBlock( - player.entityBoundingBox - .offset(it.packet.playerX, it.packet.playerY, it.packet.playerZ) - .offset(0.0,.42,0.0)) + world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid ) .2 else .42 ) + player.posY + + it.packet.playerY = pos + } } @@ -217,7 +217,7 @@ object Speed : Module( spoofUp = !spoofUp && player.onGround - if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f) { + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown) { modifyTimer(50f) spoofUp = false return @@ -231,11 +231,11 @@ object Speed : Module( event.x = -sin(yaw) * speed if (spoofUp) { event.y = min(0.0, event.y) - } else if (player.movementInput.jump) { - jump() } event.z = cos(yaw) * speed + player.setVelocity(event.x,event.y,event.z) + } } From 93241e4fea6ad876614325e71a068b011b35dcb4 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 2 May 2022 17:42:39 +0200 Subject: [PATCH 03/12] Fix formatting --- .../client/module/modules/movement/Speed.kt | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index ad4edf872..b5919bb5b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -114,42 +114,21 @@ object Speed : Module( else resetTimer() } SpeedMode.BOOST -> { - handleBoost(it) - } } } safeListener { - - if (mode == SpeedMode.BOOST) { - - if (it.packet is CPacketPlayer) { - - if (it.packet.playerMoving && spoofUp) { - - it.packet.playerIsOnGround = false - - val pos = - ( - if ( - world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid - ) - .2 - else - .42 - ) + player.posY - - it.packet.playerY = pos - - } - } - + if (mode == SpeedMode.BOOST + && it.packet is CPacketPlayer + && it.packet.playerMoving + && spoofUp + ) { + val hasRoof = world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid + it.packet.playerY = (if (hasRoof) .2 else .42) + player.posY } - } - } private fun SafeClientEvent.strafe() { @@ -214,7 +193,6 @@ object Speed : Module( } private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { - spoofUp = !spoofUp && player.onGround if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown) { @@ -234,8 +212,6 @@ object Speed : Module( } event.z = cos(yaw) * speed - player.setVelocity(event.x,event.y,event.z) - + player.setVelocity(event.x, event.y, event.z) } - } From 845688aa6b6771d319a654bd2daba3e45427a775 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 2 May 2022 17:47:51 +0200 Subject: [PATCH 04/12] Other fixes --- .../com/lambda/client/module/modules/movement/Speed.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index b5919bb5b..5aefcb24a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -6,7 +6,9 @@ import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer -import com.lambda.client.mixin.extension.* +import com.lambda.client.mixin.extension.isInWeb +import com.lambda.client.mixin.extension.playerMoving +import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.AutoEat @@ -55,7 +57,7 @@ object Speed : Module( private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND }) // boost settings - private val boostSpeed by setting("Boost Speed", .388, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST}) + private val boostSpeed by setting("Boost Speed", 0.388, 0.28..1.0, 0.01, { mode == SpeedMode.BOOST }) // Strafe Mode private var jumpTicks = 0 @@ -192,11 +194,11 @@ object Speed : Module( jumpTicks-- } - private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { + private fun SafeClientEvent.handleBoost(event: PlayerMoveEvent) { spoofUp = !spoofUp && player.onGround if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown) { - modifyTimer(50f) + resetTimer() spoofUp = false return } From 3e261e698591ef8a586cd0c924404633e5224aff Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Sat, 7 May 2022 21:25:17 +0100 Subject: [PATCH 05/12] Removed Boost mode and added YPort mode (disabling accelerate is the same as old boost mode) --- .../client/module/modules/movement/Speed.kt | 141 ++++++++---------- 1 file changed, 62 insertions(+), 79 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index ad4edf872..7dd2342e6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -1,22 +1,22 @@ package com.lambda.client.module.modules.movement +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer -import com.lambda.client.mixin.extension.* +import com.lambda.client.mixin.extension.isInWeb +import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.player.AutoEat import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.MovementUtils import com.lambda.client.util.MovementUtils.applySpeedPotionEffects import com.lambda.client.util.MovementUtils.calcMoveYaw -import com.lambda.client.util.MovementUtils.isMoving import com.lambda.client.util.MovementUtils.setSpeed import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer @@ -29,6 +29,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import java.lang.Double.max import java.lang.Double.min import kotlin.math.cos +import kotlin.math.hypot import kotlin.math.sin object Speed : Module( @@ -47,38 +48,35 @@ object Speed : Module( private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE }) private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE }) - // onGround settings - private val onGroundTimer by setting("Timer", true, { mode == SpeedMode.ONGROUND }) - private val onGroundTimerSpeed by setting("Timer Speed", 1.088f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer }) - private val onGroundSpeed by setting("Speed", 1.31f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND }) - private val onGroundSprint by setting("Sprint", true, { mode == SpeedMode.ONGROUND }) - private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND }) - - // boost settings - private val boostSpeed by setting("Boost Speed", .388, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST}) + // yport settings + // no need for speed slider as I got this shit from + // https://github.com/NoCheatPlus/NoCheatPlus/blob/master/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java + // add one if you want ig + private val accelerate by setting("Accelerate", true, { mode == SpeedMode.YPORT }) // Strafe Mode private var jumpTicks = 0 private val strafeTimer = TickTimer(TimeUnit.TICKS) - // onGround Mode - private var wasSprintEnabled = Sprint.isEnabled - private var currentMode = mode - private var spoofUp = true + // yport stuff + private var currentSpeed = .2873 + private var phase = 1 + private var lastDistance = 0.0 - enum class SpeedMode { - STRAFE, ONGROUND, BOOST + enum class SpeedMode(override val displayName: String) : DisplayEnum { + STRAFE("Strafe"), + YPORT("YPort") } init { onEnable { - wasSprintEnabled = Sprint.isEnabled + currentSpeed = .2873 + phase = 1 } onDisable { - if (!wasSprintEnabled && mode == SpeedMode.ONGROUND) Sprint.disable() runSafe { reset() } @@ -90,7 +88,7 @@ object Speed : Module( reset() } - if (mode == SpeedMode.ONGROUND && Sprint.isDisabled && onGroundSprint) Sprint.enable() + lastDistance = hypot(player.posX - player.prevPosX, player.posZ - player.prevPosZ) } safeListener { @@ -109,11 +107,7 @@ object Speed : Module( } } } - SpeedMode.ONGROUND -> { - if (shouldOnGround()) onGround() - else resetTimer() - } - SpeedMode.BOOST -> { + SpeedMode.YPORT -> { handleBoost(it) @@ -123,33 +117,22 @@ object Speed : Module( safeListener { - if (mode == SpeedMode.BOOST) { - - if (it.packet is CPacketPlayer) { + if (mode == SpeedMode.YPORT + && it.packet is CPacketPlayer + // phase is set to 3 in phase 2, so we are detecting when our speed is increased + && phase == 3) { - if (it.packet.playerMoving && spoofUp) { + val pos = ( + if (world.getBlockState(player.flooredPosition.add(.0, 2.0, .0)).isFullBlock) + .2 + else + .42 + ) + player.posY - it.packet.playerIsOnGround = false - - val pos = - ( - if ( - world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid - ) - .2 - else - .42 - ) + player.posY - - it.packet.playerY = pos - - } - } + it.packet.playerY = pos } - } - } private fun SafeClientEvent.strafe() { @@ -161,14 +144,6 @@ object Speed : Module( strafeTimer.reset() } - private fun SafeClientEvent.onGround() { - if (onGroundTimer) modifyTimer(50.0f / onGroundTimerSpeed) - else resetTimer() - - player.motionX *= onGroundSpeed - player.motionZ *= onGroundSpeed - } - private fun SafeClientEvent.shouldStrafe(): Boolean = (!player.capabilities.isFlying && !player.isElytraFlying @@ -178,18 +153,6 @@ object Speed : Module( && MovementUtils.isInputting && !(player.isInOrAboveLiquid || player.isInWeb)) - private fun SafeClientEvent.shouldOnGround(): Boolean = - (world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid || !onGroundCheckAbove) - && !AutoEat.eating - && player.isMoving - && MovementUtils.isInputting - && !player.movementInput.sneak - && player.onGround - && !(player.isInOrAboveLiquid || player.isInWeb) - && !player.capabilities.isFlying - && !player.isElytraFlying - && !mc.gameSettings.keyBindSneak.isKeyDown - private fun SafeClientEvent.reset() { player.jumpMovementFactor = 0.02f resetTimer() @@ -215,24 +178,44 @@ object Speed : Module( private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { - spoofUp = !spoofUp && player.onGround - - if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown) { - modifyTimer(50f) - spoofUp = false + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown || !player.onGround) { + resetTimer() + currentSpeed = .2873 return } modifyTimer(45.955883f) - val speed = if (spoofUp) boostSpeed else .2873 + when (phase) { + + 1 -> { + currentSpeed = max(currentSpeed, .2873) + phase = 2 + } + + 2 -> { + // NCP says hDistance < 2.15 * hDistanceBaseRef + currentSpeed *= 2.149 + phase = 3 + } + + 3 -> { + // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) + currentSpeed = if (accelerate) { + lastDistance - .66 * (lastDistance - .2873) + } else { + .2873 + } + phase = 2 + } - val yaw = calcMoveYaw() - event.x = -sin(yaw) * speed - if (spoofUp) { - event.y = min(0.0, event.y) } - event.z = cos(yaw) * speed + + val yaw = calcMoveYaw() + + event.x = -sin(yaw) * currentSpeed + event.y = min(0.0, event.y) + event.z = cos(yaw) * currentSpeed player.setVelocity(event.x,event.y,event.z) From 2437a71dfad656e9b1e8d50da25dee177c6f8381 Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Sun, 8 May 2022 13:52:22 +0100 Subject: [PATCH 06/12] Add some settings, these are in the video --- .../client/module/modules/movement/Speed.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 7dd2342e6..487181494 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -41,18 +41,21 @@ object Speed : Module( // General settings val mode by setting("Mode", SpeedMode.STRAFE) - // strafe settings + // Strafe settings private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE }) private val strafeTimerBoost by setting("Timer Boost", true, { mode == SpeedMode.STRAFE }) private val strafeAutoJump by setting("Auto Jump", true, { mode == SpeedMode.STRAFE }) private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE }) private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE }) - // yport settings - // no need for speed slider as I got this shit from - // https://github.com/NoCheatPlus/NoCheatPlus/blob/master/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java - // add one if you want ig - private val accelerate by setting("Accelerate", true, { mode == SpeedMode.YPORT }) + // YPort settings + + private val yPortAccelerate by setting("Accelerate", true, { mode == SpeedMode.YPORT }) + private val yPortStrict by setting("Strict", false, { mode == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") + private val yPortCustomValues by setting("Custom Values", false, { mode == SpeedMode.YPORT }) + private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) + private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) + // Strafe Mode private var jumpTicks = 0 @@ -178,7 +181,8 @@ object Speed : Module( private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { - if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown || !player.onGround) { + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown + || !player.onGround || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict) { resetTimer() currentSpeed = .2873 return @@ -195,14 +199,14 @@ object Speed : Module( 2 -> { // NCP says hDistance < 2.15 * hDistanceBaseRef - currentSpeed *= 2.149 + currentSpeed *= if (yPortCustomValues) yPortAcceleration else 2.149 phase = 3 } 3 -> { // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) - currentSpeed = if (accelerate) { - lastDistance - .66 * (lastDistance - .2873) + currentSpeed = if (yPortAccelerate) { + lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) } else { .2873 } From e0e140fc9eb9c243c8590ec43501be0dfb287e80 Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Tue, 10 May 2022 18:11:07 +0100 Subject: [PATCH 07/12] YPort update No32767 Added maximum speed slider Added Air Strict mode to emulate Y motion better Inflicted pain on Doogie13 --- .../client/module/modules/movement/Speed.kt | 118 +++++++++++++++--- 1 file changed, 100 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 487181494..8b84495e1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -21,10 +21,12 @@ import com.lambda.client.util.MovementUtils.setSpeed import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit +import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.settings.KeyBinding import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraftforge.fml.common.gameevent.TickEvent import java.lang.Double.max import java.lang.Double.min @@ -49,9 +51,10 @@ object Speed : Module( private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE }) // YPort settings - private val yPortAccelerate by setting("Accelerate", true, { mode == SpeedMode.YPORT }) - private val yPortStrict by setting("Strict", false, { mode == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") + private val yPortStrict by setting("Head Strict", false, { mode == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") + private val yPortAirStrict by setting("Air Strict", false, { mode == SpeedMode.YPORT }, description = "Force YPort to handle Y movement differently, slows this down A LOT") + private val yPortMaxSpeed by setting("Maximum Speed", 0.0, 0.0..2.0, 0.001, { mode == SpeedMode.YPORT }) private val yPortCustomValues by setting("Custom Values", false, { mode == SpeedMode.YPORT }) private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) @@ -65,7 +68,10 @@ object Speed : Module( // yport stuff private var currentSpeed = .2873 + private var currentY = 0.0 private var phase = 1 + private var prevPhase = 1 + private var goUp = false private var lastDistance = 0.0 enum class SpeedMode(override val displayName: String) : DisplayEnum { @@ -77,6 +83,9 @@ object Speed : Module( onEnable { currentSpeed = .2873 phase = 1 + prevPhase = 1 + goUp = false + currentY = 0.0 } onDisable { @@ -123,19 +132,60 @@ object Speed : Module( if (mode == SpeedMode.YPORT && it.packet is CPacketPlayer // phase is set to 3 in phase 2, so we are detecting when our speed is increased - && phase == 3) { + && goUp) { + + + var pos = ( + if (world.getBlockState(player.flooredPosition.add(.0, 2.0, .0)).isFullBlock) + .2 + else + .42 + ) + + if (currentY > 0.0) + pos = currentY + else if (yPortAirStrict && phase == 4 && prevPhase == 4) { + + var predictedY = currentY + predictedY -= 0.08 + predictedY *= 0.9800000190734863 + + if (predictedY < 0.0) { + phase = 0 + MessageSendHelper.sendChatMessage("YPort: Phase 0") + } + + } + + it.packet.playerY = pos + player.posY - val pos = ( - if (world.getBlockState(player.flooredPosition.add(.0, 2.0, .0)).isFullBlock) - .2 - else - .42 - ) + player.posY + MessageSendHelper.sendChatMessage("^^^ $pos $phase") + currentY = pos - it.packet.playerY = pos + } else if (mode == SpeedMode.YPORT + && it.packet is CPacketPlayer + && !goUp) { + + MessageSendHelper.sendChatMessage("vvv 0.0 $phase") } } + + safeListener { + + if (mode == SpeedMode.YPORT) + if (it.packet is SPacketPlayerPosLook) { + + currentSpeed = 0.0 + currentY = 0.0 + goUp = false + phase = 0 + + } + + + } + } private fun SafeClientEvent.strafe() { @@ -179,7 +229,7 @@ object Speed : Module( jumpTicks-- } - private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) { + private fun SafeClientEvent.handleBoost(event: PlayerMoveEvent) { if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown || !player.onGround || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict) { @@ -192,18 +242,19 @@ object Speed : Module( when (phase) { - 1 -> { - currentSpeed = max(currentSpeed, .2873) - phase = 2 - } - 2 -> { + prevPhase = 2 + // NCP says hDistance < 2.15 * hDistanceBaseRef currentSpeed *= if (yPortCustomValues) yPortAcceleration else 2.149 - phase = 3 + phase = if (yPortAirStrict) 4 else 3 + goUp = true + currentY = 0.0 } 3 -> { + prevPhase = 3 + // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) currentSpeed = if (yPortAccelerate) { lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) @@ -211,17 +262,48 @@ object Speed : Module( .2873 } phase = 2 + goUp = false + } + + 4 -> { + + if (prevPhase == 2) + currentSpeed = if (yPortAccelerate) { + lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) + } else { + .2873 + } + + prevPhase = 4 + + goUp = true + + currentSpeed -= currentSpeed / 159 + + currentY -= 0.08 + currentY *= 0.9800000190734863 + } + else -> { + prevPhase = 1 + + currentSpeed = max(currentSpeed, .2873) + phase++ + goUp = false + } } val yaw = calcMoveYaw() + if (yPortMaxSpeed != 0.0) + currentSpeed = currentSpeed.coerceAtMost(yPortMaxSpeed) + event.x = -sin(yaw) * currentSpeed event.y = min(0.0, event.y) event.z = cos(yaw) * currentSpeed - player.setVelocity(event.x,event.y,event.z) + player.setVelocity(event.x, event.y, event.z) } From c55f10803b38590cd419c6f683000b4416cbb6be Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Tue, 10 May 2022 18:53:53 +0100 Subject: [PATCH 08/12] Fixed YPort AirStrict to make it calculate motion properly this time Removed debug messages --- .../client/module/modules/movement/Speed.kt | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 8b84495e1..d949f5ee7 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -21,7 +21,6 @@ import com.lambda.client.util.MovementUtils.setSpeed import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.settings.KeyBinding @@ -135,40 +134,35 @@ object Speed : Module( && goUp) { - var pos = ( + var offset = ( if (world.getBlockState(player.flooredPosition.add(.0, 2.0, .0)).isFullBlock) .2 else .42 ) - if (currentY > 0.0) - pos = currentY + val unModOffset = offset + + if (currentY + unModOffset > 0) + offset += currentY else if (yPortAirStrict && phase == 4 && prevPhase == 4) { var predictedY = currentY predictedY -= 0.08 - predictedY *= 0.9800000190734863 + predictedY *= 0.9800000190734863 // 0.333200006 vs 0.341599999 - if (predictedY < 0.0) { + if (predictedY + player.posY <= player.posY) { phase = 0 - MessageSendHelper.sendChatMessage("YPort: Phase 0") } } - it.packet.playerY = pos + player.posY - - MessageSendHelper.sendChatMessage("^^^ $pos $phase") - currentY = pos + it.packet.playerY = (offset + player.posY) - } else if (mode == SpeedMode.YPORT - && it.packet is CPacketPlayer - && !goUp) { - - MessageSendHelper.sendChatMessage("vvv 0.0 $phase") + currentY = offset - unModOffset } + } safeListener { @@ -179,7 +173,8 @@ object Speed : Module( currentSpeed = 0.0 currentY = 0.0 goUp = false - phase = 0 + // 3 extra ticks at base speed + phase = -3 } From bc830212fbea4178254db20c283703a7b1938d4f Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Thu, 29 Sep 2022 08:04:31 +0100 Subject: [PATCH 09/12] Clean up --- .../client/module/modules/movement/Speed.kt | 133 +++++++++--------- 1 file changed, 70 insertions(+), 63 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index d949f5ee7..b5703a655 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -12,7 +12,6 @@ import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.MovementUtils import com.lambda.client.util.MovementUtils.applySpeedPotionEffects @@ -33,6 +32,7 @@ import kotlin.math.cos import kotlin.math.hypot import kotlin.math.sin + object Speed : Module( name = "Speed", description = "Move faster", @@ -58,6 +58,7 @@ object Speed : Module( private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) + private const val TIMER_SPEED = 45.955883f // Strafe Mode private var jumpTicks = 0 @@ -68,11 +69,19 @@ object Speed : Module( // yport stuff private var currentSpeed = .2873 private var currentY = 0.0 - private var phase = 1 - private var prevPhase = 1 + private var phase : YPortPhase = YPortPhase.WALKING + private var prevPhase : YPortPhase = YPortPhase.WALKING private var goUp = false private var lastDistance = 0.0 + private enum class YPortPhase { + WAITING, + WALKING, + ACCELERATING, + SLOWDOWN, + FALLING + } + enum class SpeedMode(override val displayName: String) : DisplayEnum { STRAFE("Strafe"), YPORT("YPort") @@ -81,8 +90,8 @@ object Speed : Module( init { onEnable { currentSpeed = .2873 - phase = 1 - prevPhase = 1 + phase = YPortPhase.WALKING + prevPhase = YPortPhase.WALKING goUp = false currentY = 0.0 } @@ -103,14 +112,17 @@ object Speed : Module( } safeListener { - if (mode == SpeedMode.STRAFE && shouldStrafe()) strafe() + if (mode == SpeedMode.STRAFE + && shouldStrafe() + ) strafe() } safeListener { when (mode) { SpeedMode.STRAFE -> { - if (shouldStrafe()) setSpeed(max(player.speed, applySpeedPotionEffects(0.2873))) - else { + if (shouldStrafe()) { + setSpeed(max(player.speed, applySpeedPotionEffects(0.2873))) + } else { reset() if (strafeCancelInertia && !strafeTimer.tick(2L, false)) { player.motionX = 0.0 @@ -119,74 +131,65 @@ object Speed : Module( } } SpeedMode.YPORT -> { - handleBoost(it) - } } } safeListener { + if (mode != SpeedMode.YPORT + || it.packet !is CPacketPlayer + || !goUp + ) return@safeListener - if (mode == SpeedMode.YPORT - && it.packet is CPacketPlayer - // phase is set to 3 in phase 2, so we are detecting when our speed is increased - && goUp) { + var offset = .42 + //.015625 is the largest number that block heights are always divisible + while (world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0, offset, .0))) { - var offset = ( - if (world.getBlockState(player.flooredPosition.add(.0, 2.0, .0)).isFullBlock) - .2 - else - .42 - ) + if (offset <= 0) + break - val unModOffset = offset + offset -= .015625 - if (currentY + unModOffset > 0) - offset += currentY - else if (yPortAirStrict && phase == 4 && prevPhase == 4) { + } - var predictedY = currentY - predictedY -= 0.08 - predictedY *= 0.9800000190734863 // 0.333200006 vs 0.341599999 + val unModOffset = offset - if (predictedY + player.posY <= player.posY) { - phase = 0 - } + if (currentY + unModOffset > 0) + offset += currentY + else if (yPortAirStrict && phase == YPortPhase.FALLING && prevPhase == YPortPhase.FALLING) { - } + var predictedY = currentY + predictedY -= 0.08 + predictedY *= 0.9800000190734863 // 0.333200006 vs 0.341599999 - it.packet.playerY = (offset + player.posY) - - currentY = offset - unModOffset + if (predictedY + player.posY <= player.posY) { + phase = YPortPhase.WAITING + } } + it.packet.playerY = (offset + player.posY) + + currentY = offset - unModOffset } safeListener { + if (mode != SpeedMode.YPORT || it.packet !is SPacketPlayerPosLook) return@safeListener - if (mode == SpeedMode.YPORT) - if (it.packet is SPacketPlayerPosLook) { - - currentSpeed = 0.0 - currentY = 0.0 - goUp = false - // 3 extra ticks at base speed - phase = -3 - - } - - + currentSpeed = 0.0 + currentY = 0.0 + goUp = false + // 3 extra ticks at base speed + phase = YPortPhase.WAITING } - } private fun SafeClientEvent.strafe() { player.jumpMovementFactor = strafeAirSpeedBoost // slightly slower timer speed bypasses better (1.088) - if (strafeTimerBoost) modifyTimer(45.955883f) + if (strafeTimerBoost) modifyTimer(TIMER_SPEED) if ((Step.isDisabled || !player.collidedHorizontally) && strafeAutoJump) jump() strafeTimer.reset() @@ -226,29 +229,35 @@ object Speed : Module( private fun SafeClientEvent.handleBoost(event: PlayerMoveEvent) { - if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown - || !player.onGround || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict) { + if ( + player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f + || player.isInOrAboveLiquid + || mc.gameSettings.keyBindJump.isKeyDown + || !player.onGround + || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict + ) + { resetTimer() currentSpeed = .2873 return } - modifyTimer(45.955883f) + modifyTimer(TIMER_SPEED) + + prevPhase = YPortPhase.ACCELERATING when (phase) { - 2 -> { - prevPhase = 2 + YPortPhase.ACCELERATING -> { // NCP says hDistance < 2.15 * hDistanceBaseRef currentSpeed *= if (yPortCustomValues) yPortAcceleration else 2.149 - phase = if (yPortAirStrict) 4 else 3 + phase = if (yPortAirStrict) YPortPhase.FALLING else YPortPhase.SLOWDOWN goUp = true currentY = 0.0 } - 3 -> { - prevPhase = 3 + YPortPhase.SLOWDOWN -> { // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) currentSpeed = if (yPortAccelerate) { @@ -256,21 +265,19 @@ object Speed : Module( } else { .2873 } - phase = 2 + phase = YPortPhase.ACCELERATING goUp = false } - 4 -> { + YPortPhase.FALLING -> { - if (prevPhase == 2) + if (prevPhase == YPortPhase.WALKING) currentSpeed = if (yPortAccelerate) { lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) } else { .2873 } - prevPhase = 4 - goUp = true currentSpeed -= currentSpeed / 159 @@ -281,10 +288,10 @@ object Speed : Module( } else -> { - prevPhase = 1 + prevPhase = YPortPhase.WALKING currentSpeed = max(currentSpeed, .2873) - phase++ + phase = YPortPhase.values()[phase.ordinal + 1 % YPortPhase.values().size] goUp = false } } From e3fb45776ac31280aff8459d31f6e194ca30c06e Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Thu, 29 Sep 2022 08:09:46 +0100 Subject: [PATCH 10/12] Clean up 2 --- .../com/lambda/client/module/modules/movement/Speed.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index b5703a655..4301626d1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -75,10 +75,15 @@ object Speed : Module( private var lastDistance = 0.0 private enum class YPortPhase { + // to help with bypassing right after setback WAITING, + // to get some speed initially WALKING, + // to jump and accelerate ACCELERATING, + // to fall to the ground SLOWDOWN, + // to slowly fall to the ground FALLING } @@ -244,7 +249,7 @@ object Speed : Module( modifyTimer(TIMER_SPEED) - prevPhase = YPortPhase.ACCELERATING + prevPhase = phase when (phase) { @@ -288,8 +293,6 @@ object Speed : Module( } else -> { - prevPhase = YPortPhase.WALKING - currentSpeed = max(currentSpeed, .2873) phase = YPortPhase.values()[phase.ordinal + 1 % YPortPhase.values().size] goUp = false From b3c0ff84430d29deabf4d8ec9590abbea7fdd9cc Mon Sep 17 00:00:00 2001 From: Constructor Date: Fri, 30 Sep 2022 02:54:59 +0200 Subject: [PATCH 11/12] Another cleanup --- .../client/module/modules/combat/HoleSnap.kt | 2 +- .../client/module/modules/combat/Surround.kt | 2 +- .../client/module/modules/movement/Speed.kt | 66 ++++++++----------- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt index cdb4023f3..f590ca671 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt @@ -94,7 +94,7 @@ object HoleSnap : Module( } getHole()?.let { - if (disableStrafe && Speed.mode == Speed.SpeedMode.STRAFE) Speed.disable() + if (disableStrafe && Speed.mode.value == Speed.SpeedMode.STRAFE) Speed.disable() if ((airStrafe || player.onGround) && !player.isCentered(it)) { val playerPos = player.positionVector val targetPos = Vec3d(it.x + 0.5, player.posY, it.z + 0.5) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt index 34ffedfba..f8dde7012 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt @@ -101,7 +101,7 @@ object Surround : Module( // Centered check if (!player.centerPlayer()) return@safeListener - if (disableStrafe && Speed.mode == Speed.SpeedMode.STRAFE) { + if (disableStrafe && Speed.mode.value == Speed.SpeedMode.STRAFE) { Speed.disable() } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 4301626d1..8ca81d545 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -40,23 +40,23 @@ object Speed : Module( modulePriority = 100 ) { // General settings - val mode by setting("Mode", SpeedMode.STRAFE) + val mode = setting("Mode", SpeedMode.STRAFE) // Strafe settings - private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE }) - private val strafeTimerBoost by setting("Timer Boost", true, { mode == SpeedMode.STRAFE }) - private val strafeAutoJump by setting("Auto Jump", true, { mode == SpeedMode.STRAFE }) - private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE }) - private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE }) + private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode.value == SpeedMode.STRAFE }) + private val strafeTimerBoost by setting("Timer Boost", true, { mode.value == SpeedMode.STRAFE }) + private val strafeAutoJump by setting("Auto Jump", true, { mode.value == SpeedMode.STRAFE }) + private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode.value == SpeedMode.STRAFE }) + private val strafeCancelInertia by setting("Cancel Inertia", false, { mode.value == SpeedMode.STRAFE }) // YPort settings - private val yPortAccelerate by setting("Accelerate", true, { mode == SpeedMode.YPORT }) - private val yPortStrict by setting("Head Strict", false, { mode == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") - private val yPortAirStrict by setting("Air Strict", false, { mode == SpeedMode.YPORT }, description = "Force YPort to handle Y movement differently, slows this down A LOT") - private val yPortMaxSpeed by setting("Maximum Speed", 0.0, 0.0..2.0, 0.001, { mode == SpeedMode.YPORT }) - private val yPortCustomValues by setting("Custom Values", false, { mode == SpeedMode.YPORT }) - private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) - private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode == SpeedMode.YPORT && yPortCustomValues }) + private val yPortAccelerate by setting("Accelerate", true, { mode.value == SpeedMode.YPORT }) + private val yPortStrict by setting("Head Strict", false, { mode.value == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") + private val yPortAirStrict by setting("Air Strict", false, { mode.value == SpeedMode.YPORT }, description = "Force YPort to handle Y movement differently, slows this down A LOT") + private val yPortMaxSpeed by setting("Maximum Speed", 0.0, 0.0..2.0, 0.001, { mode.value == SpeedMode.YPORT }) + private val yPortCustomValues by setting("Custom Values", false, { mode.value == SpeedMode.YPORT }) + private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode.value == SpeedMode.YPORT && yPortCustomValues }) + private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode.value == SpeedMode.YPORT && yPortCustomValues }) private const val TIMER_SPEED = 45.955883f @@ -64,13 +64,11 @@ object Speed : Module( private var jumpTicks = 0 private val strafeTimer = TickTimer(TimeUnit.TICKS) - private var currentMode = mode - // yport stuff private var currentSpeed = .2873 private var currentY = 0.0 - private var phase : YPortPhase = YPortPhase.WALKING - private var prevPhase : YPortPhase = YPortPhase.WALKING + private var phase: YPortPhase = YPortPhase.WALKING + private var prevPhase: YPortPhase = YPortPhase.WALKING private var goUp = false private var lastDistance = 0.0 @@ -108,22 +106,17 @@ object Speed : Module( } safeListener { - if (mode != currentMode) { - currentMode = mode - reset() - } - lastDistance = hypot(player.posX - player.prevPosX, player.posZ - player.prevPosZ) } safeListener { - if (mode == SpeedMode.STRAFE + if (mode.value == SpeedMode.STRAFE && shouldStrafe() ) strafe() } safeListener { - when (mode) { + when (mode.value) { SpeedMode.STRAFE -> { if (shouldStrafe()) { setSpeed(max(player.speed, applySpeedPotionEffects(0.2873))) @@ -135,6 +128,7 @@ object Speed : Module( } } } + SpeedMode.YPORT -> { handleBoost(it) } @@ -142,7 +136,7 @@ object Speed : Module( } safeListener { - if (mode != SpeedMode.YPORT + if (mode.value != SpeedMode.YPORT || it.packet !is CPacketPlayer || !goUp ) return@safeListener @@ -151,12 +145,10 @@ object Speed : Module( //.015625 is the largest number that block heights are always divisible while (world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0, offset, .0))) { - if (offset <= 0) break offset -= .015625 - } val unModOffset = offset @@ -181,7 +173,7 @@ object Speed : Module( } safeListener { - if (mode != SpeedMode.YPORT || it.packet !is SPacketPlayerPosLook) return@safeListener + if (mode.value != SpeedMode.YPORT || it.packet !is SPacketPlayerPosLook) return@safeListener currentSpeed = 0.0 currentY = 0.0 @@ -189,6 +181,10 @@ object Speed : Module( // 3 extra ticks at base speed phase = YPortPhase.WAITING } + + mode.listeners.add { + runSafe { reset() } + } } private fun SafeClientEvent.strafe() { @@ -233,15 +229,12 @@ object Speed : Module( } private fun SafeClientEvent.handleBoost(event: PlayerMoveEvent) { - - if ( - player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f || player.isInOrAboveLiquid || mc.gameSettings.keyBindJump.isKeyDown || !player.onGround || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict - ) - { + ) { resetTimer() currentSpeed = .2873 return @@ -252,9 +245,7 @@ object Speed : Module( prevPhase = phase when (phase) { - YPortPhase.ACCELERATING -> { - // NCP says hDistance < 2.15 * hDistanceBaseRef currentSpeed *= if (yPortCustomValues) yPortAcceleration else 2.149 phase = if (yPortAirStrict) YPortPhase.FALLING else YPortPhase.SLOWDOWN @@ -263,7 +254,6 @@ object Speed : Module( } YPortPhase.SLOWDOWN -> { - // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) currentSpeed = if (yPortAccelerate) { lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) @@ -275,7 +265,6 @@ object Speed : Module( } YPortPhase.FALLING -> { - if (prevPhase == YPortPhase.WALKING) currentSpeed = if (yPortAccelerate) { lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) @@ -289,7 +278,6 @@ object Speed : Module( currentY -= 0.08 currentY *= 0.9800000190734863 - } else -> { @@ -309,7 +297,5 @@ object Speed : Module( event.z = cos(yaw) * currentSpeed player.setVelocity(event.x, event.y, event.z) - } - } From 2c2ca542dec8a5bc929a61db117f4e8e148038f0 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 30 Oct 2022 01:20:58 +0200 Subject: [PATCH 12/12] Added working 42 km/h overhead strafe for 2b --- .../client/module/modules/movement/Speed.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 8ca81d545..83dfb26c5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -45,7 +45,8 @@ object Speed : Module( // Strafe settings private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode.value == SpeedMode.STRAFE }) private val strafeTimerBoost by setting("Timer Boost", true, { mode.value == SpeedMode.STRAFE }) - private val strafeAutoJump by setting("Auto Jump", true, { mode.value == SpeedMode.STRAFE }) + private val strafeAutoJump by setting("Auto Jump", true, { mode.value == SpeedMode.STRAFE }, description = "WARNING: Food intensive!") + private val strafeOnlyOverhead by setting("Only strafe on overhead", false, { mode.value == SpeedMode.STRAFE && strafeAutoJump }) private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode.value == SpeedMode.STRAFE }) private val strafeCancelInertia by setting("Cancel Inertia", false, { mode.value == SpeedMode.STRAFE }) @@ -54,9 +55,8 @@ object Speed : Module( private val yPortStrict by setting("Head Strict", false, { mode.value == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") private val yPortAirStrict by setting("Air Strict", false, { mode.value == SpeedMode.YPORT }, description = "Force YPort to handle Y movement differently, slows this down A LOT") private val yPortMaxSpeed by setting("Maximum Speed", 0.0, 0.0..2.0, 0.001, { mode.value == SpeedMode.YPORT }) - private val yPortCustomValues by setting("Custom Values", false, { mode.value == SpeedMode.YPORT }) - private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode.value == SpeedMode.YPORT && yPortCustomValues }) - private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode.value == SpeedMode.YPORT && yPortCustomValues }) + private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode.value == SpeedMode.YPORT }) + private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode.value == SpeedMode.YPORT }) private const val TIMER_SPEED = 45.955883f @@ -107,9 +107,6 @@ object Speed : Module( safeListener { lastDistance = hypot(player.posX - player.prevPosX, player.posZ - player.prevPosZ) - } - - safeListener { if (mode.value == SpeedMode.STRAFE && shouldStrafe() ) strafe() @@ -164,7 +161,6 @@ object Speed : Module( if (predictedY + player.posY <= player.posY) { phase = YPortPhase.WAITING } - } it.packet.playerY = (offset + player.posY) @@ -191,19 +187,21 @@ object Speed : Module( player.jumpMovementFactor = strafeAirSpeedBoost // slightly slower timer speed bypasses better (1.088) if (strafeTimerBoost) modifyTimer(TIMER_SPEED) - if ((Step.isDisabled || !player.collidedHorizontally) && strafeAutoJump) jump() + + if ((Step.isDisabled || player.onGround) && strafeAutoJump) jump() strafeTimer.reset() } private fun SafeClientEvent.shouldStrafe(): Boolean = - (!player.capabilities.isFlying + !player.capabilities.isFlying && !player.isElytraFlying && !mc.gameSettings.keyBindSneak.isKeyDown && (!strafeOnHoldingSprint || mc.gameSettings.keyBindSprint.isKeyDown) && !BaritoneUtils.isPathing && MovementUtils.isInputting - && !(player.isInOrAboveLiquid || player.isInWeb)) + && !(player.isInOrAboveLiquid || player.isInWeb) + && (!strafeOnlyOverhead || world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0,.42,.0))) private fun SafeClientEvent.reset() { player.jumpMovementFactor = 0.02f @@ -247,7 +245,7 @@ object Speed : Module( when (phase) { YPortPhase.ACCELERATING -> { // NCP says hDistance < 2.15 * hDistanceBaseRef - currentSpeed *= if (yPortCustomValues) yPortAcceleration else 2.149 + currentSpeed *= yPortAcceleration phase = if (yPortAirStrict) YPortPhase.FALLING else YPortPhase.SLOWDOWN goUp = true currentY = 0.0 @@ -256,7 +254,7 @@ object Speed : Module( YPortPhase.SLOWDOWN -> { // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) currentSpeed = if (yPortAccelerate) { - lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) + lastDistance - yPortDecay * (lastDistance - .2873) } else { .2873 } @@ -265,12 +263,13 @@ object Speed : Module( } YPortPhase.FALLING -> { - if (prevPhase == YPortPhase.WALKING) + if (prevPhase == YPortPhase.WALKING) { currentSpeed = if (yPortAccelerate) { - lastDistance - (if (yPortCustomValues) yPortDecay else .66) * (lastDistance - .2873) + lastDistance - yPortDecay * (lastDistance - .2873) } else { .2873 } + } goUp = true @@ -289,8 +288,9 @@ object Speed : Module( val yaw = calcMoveYaw() - if (yPortMaxSpeed != 0.0) + if (yPortMaxSpeed != 0.0) { currentSpeed = currentSpeed.coerceAtMost(yPortMaxSpeed) + } event.x = -sin(yaw) * currentSpeed event.y = min(0.0, event.y)