From d40edc5ba231dd16b43d6a19375bcb1ef1d6a7b8 Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Mon, 22 May 2023 17:04:16 -0500 Subject: [PATCH 1/8] Added Speed Threshold to Vanilla efly mode --- .../gui/hudgui/elements/player/PlayerSpeed.kt | 2 +- .../module/modules/movement/ElytraFlight.kt | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt index d1aced7b3..76874ebd3 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt @@ -23,7 +23,7 @@ internal object PlayerSpeed : LabelHud( MPH("mph", 2.237) // Monkey Americans } - private val speedList = ArrayDeque() + val speedList = ArrayDeque() override fun SafeClientEvent.updateText() { updateSpeedList() diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 13d7e12a9..6788dcf5a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -12,6 +12,7 @@ import com.lambda.client.mixin.extension.timer import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.LagNotifier +import com.lambda.client.gui.hudgui.elements.player.PlayerSpeed.speedList import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.math.Vec2f @@ -95,9 +96,11 @@ object ElytraFlight : Module( /* Vanilla */ - private val upPitch by setting("Up Pitch", 30f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) - private val downPitch by setting("Down Pitch", 0f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) - private val rocketPitch by setting("Rocket Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val rocketPitch by setting("Rocket Pitch", 50f, 20f..80f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are boosted by a rocket, this pitch will be used") + private val upPitch by setting("Up Pitch", 30f, 0f..60f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used") + private val downPitch by setting("Down Pitch", 0f, -30f..50f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down") + private val controlSpeed by setting("Control Speed", true, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Enable to set a speed threshold value") + private val speedThreshold by setting("Speed Threshold", 26, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use up pitch") /* End of Mode Settings */ @@ -128,8 +131,7 @@ object ElytraFlight : Module( private var boostingTick = 0 /* Vanilla mode state */ - private var firstY = 0.0 - private var secondY = 0.0 + private var upPitchTimer: Long = 0 /* Event Listeners */ init { @@ -483,13 +485,13 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { - secondY = player.posY packetPitch = when { - world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch - firstY - secondY > 0 -> downPitch - else -> -upPitch - } - firstY = player.posY + world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch + player.motionY > 0 || player.movementInput.jump || System.currentTimeMillis() < upPitchTimer -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch + controlSpeed && (if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size) > speedThreshold -> { //(This is the only way I was able to get the player speed) If controlSpeed is enabled and the speed is over the speedThreshold, then.... + upPitchTimer = System.currentTimeMillis() + 1000 //Set upPitchTimer for 1 second + -upPitch} //Use -upPitch + else -> downPitch} // If none of the other conditions are met, use downPitch } fun shouldSwing(): Boolean { From ed8a7f904c9fb81b0cc404cf53ffad72326e697e Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Mon, 22 May 2023 22:12:44 -0500 Subject: [PATCH 2/8] Elytra gains hight --- .../client/module/modules/movement/ElytraFlight.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 6788dcf5a..744276396 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -97,10 +97,12 @@ object ElytraFlight : Module( /* Vanilla */ private val rocketPitch by setting("Rocket Pitch", 50f, 20f..80f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are boosted by a rocket, this pitch will be used") - private val upPitch by setting("Up Pitch", 30f, 0f..60f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used") - private val downPitch by setting("Down Pitch", 0f, -30f..50f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down") + private val upPitch by setting("Up Pitch", 37.5f, 0f..60f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used") + private val downPitch by setting("Down Pitch", 35f, -30f..50f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down") private val controlSpeed by setting("Control Speed", true, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Enable to set a speed threshold value") - private val speedThreshold by setting("Speed Threshold", 26, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use up pitch") + private val speedThreshold by setting("Speed Threshold", 43, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use up pitch") + private val descendSpeedFactor by setting("Descend Speed Factor", 2.75f, 1f..5f, 0.25f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }) + private val descendPitchFactor by setting("Descend Pitch Factor", 4f, 1f..5f, 0.25f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }) /* End of Mode Settings */ @@ -485,12 +487,14 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { + var playerSpeedCal = if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size packetPitch = when { world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch player.motionY > 0 || player.movementInput.jump || System.currentTimeMillis() < upPitchTimer -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch - controlSpeed && (if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size) > speedThreshold -> { //(This is the only way I was able to get the player speed) If controlSpeed is enabled and the speed is over the speedThreshold, then.... + controlSpeed && playerSpeedCal > speedThreshold -> { //(This is the only way I was able to get the player speed) If controlSpeed is enabled and the speed is over the speedThreshold, then.... upPitchTimer = System.currentTimeMillis() + 1000 //Set upPitchTimer for 1 second -upPitch} //Use -upPitch + controlSpeed && playerSpeedCal < speedThreshold/descendSpeedFactor -> downPitch/descendPitchFactor //When the player is moving slower, this code can make the pitch less extreme else -> downPitch} // If none of the other conditions are met, use downPitch } From 0bba35b94e6b7cec95ba298c9b7254b964de805d Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Thu, 25 May 2023 06:39:35 -0500 Subject: [PATCH 3/8] Improved pitch controls --- .../module/modules/movement/ElytraFlight.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 744276396..2288f317f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -99,10 +99,9 @@ object ElytraFlight : Module( private val rocketPitch by setting("Rocket Pitch", 50f, 20f..80f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are boosted by a rocket, this pitch will be used") private val upPitch by setting("Up Pitch", 37.5f, 0f..60f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used") private val downPitch by setting("Down Pitch", 35f, -30f..50f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down") - private val controlSpeed by setting("Control Speed", true, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Enable to set a speed threshold value") - private val speedThreshold by setting("Speed Threshold", 43, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use up pitch") - private val descendSpeedFactor by setting("Descend Speed Factor", 2.75f, 1f..5f, 0.25f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }) - private val descendPitchFactor by setting("Descend Pitch Factor", 4f, 1f..5f, 0.25f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }) + private val controlSpeed by setting("Control Speed", true, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Enable to set pitch controls based on your speed") + private val speedThreshold by setting("Speed Threshold", 43, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use the Up Pitch value") + private val slowPercentage by setting("Slow Percentage", 45, 1..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "Rotates the pitch into the Down Pitch value. Low percents rotate fast, high percents rotate slow") /* End of Mode Settings */ @@ -487,14 +486,15 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { - var playerSpeedCal = if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size + var playerSpeedCal = if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size //This is the only way I found to get the player speed + var speedPercentOfMax = (playerSpeedCal/speedThreshold*100).toFloat() //This is used to calulate the percent of the max speed. 50 means 50% packetPitch = when { world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch - player.motionY > 0 || player.movementInput.jump || System.currentTimeMillis() < upPitchTimer -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch - controlSpeed && playerSpeedCal > speedThreshold -> { //(This is the only way I was able to get the player speed) If controlSpeed is enabled and the speed is over the speedThreshold, then.... + player.motionY > 0 || System.currentTimeMillis() < upPitchTimer || player.movementInput.jump -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch + controlSpeed && playerSpeedCal > speedThreshold -> { //If controlSpeed is enabled and the speed is over the speedThreshold, then.... upPitchTimer = System.currentTimeMillis() + 1000 //Set upPitchTimer for 1 second -upPitch} //Use -upPitch - controlSpeed && playerSpeedCal < speedThreshold/descendSpeedFactor -> downPitch/descendPitchFactor //When the player is moving slower, this code can make the pitch less extreme + controlSpeed && speedPercentOfMax < slowPercentage -> speedPercentOfMax/slowPercentage*downPitch //Simple expression that slowly curves the pitch into downPitch else -> downPitch} // If none of the other conditions are met, use downPitch } From f2da0e2aab0b4561eb3a149dd6cfcd6cff9176a2 Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Sun, 28 May 2023 23:09:29 -0500 Subject: [PATCH 4/8] Fixed playerSpeed --- .../gui/hudgui/elements/player/PlayerSpeed.kt | 2 +- .../module/modules/combat/AutoOffhand.kt | 10 +++---- .../module/modules/movement/ElytraFlight.kt | 27 +++++++++---------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt index 76874ebd3..d1aced7b3 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt @@ -23,7 +23,7 @@ internal object PlayerSpeed : LabelHud( MPH("mph", 2.237) // Monkey Americans } - val speedList = ArrayDeque() + private val speedList = ArrayDeque() override fun SafeClientEvent.updateText() { updateSpeedList() diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 441782e46..ffdec99d9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -117,7 +117,7 @@ object AutoOffhand : Module( else -> null } - private fun SafeClientEvent.checkTotem() = player.scaledHealth < hpThreshold + private fun SafeClientEvent.checkTotem() = player.scaledHealth < hpThreshold || (checkDamage && player.scaledHealth - maxDamage < hpThreshold) private fun SafeClientEvent.checkGapple() = offhandGapple @@ -189,12 +189,8 @@ object AutoOffhand : Module( if (player.getDistance(entity) > 10.0f) continue when { - mob && entity is EntityMob -> { - maxDamage = max(calcDamageFromMob(entity), maxDamage) - } - this@AutoOffhand.player && entity is EntityPlayer -> { - maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage) - } + mob && entity is EntityMob -> maxDamage = max(calcDamageFromMob(entity), maxDamage) + this@AutoOffhand.player && entity is EntityPlayer -> maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage) crystal && entity is EntityEnderCrystal -> { val damage = CombatManager.crystalMap[entity] ?: continue maxDamage = max(damage.selfDamage, maxDamage) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 2288f317f..8f547f2f1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -5,6 +5,7 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket +import com.lambda.client.manager.managers.TimerManager import com.lambda.client.mixin.extension.boostedEntity import com.lambda.client.mixin.extension.playerPosLookPitch import com.lambda.client.mixin.extension.tickLength @@ -12,7 +13,6 @@ import com.lambda.client.mixin.extension.timer import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.LagNotifier -import com.lambda.client.gui.hudgui.elements.player.PlayerSpeed.speedList import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.math.Vec2f @@ -96,12 +96,12 @@ object ElytraFlight : Module( /* Vanilla */ - private val rocketPitch by setting("Rocket Pitch", 50f, 20f..80f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are boosted by a rocket, this pitch will be used") - private val upPitch by setting("Up Pitch", 37.5f, 0f..60f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used") - private val downPitch by setting("Down Pitch", 35f, -30f..50f, 2.5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down") + private val rocketPitch by setting("Rocket Pitch", 50f, 20f..80f, 2f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are boosted by a rocket, this pitch will be used. Note: on 2B2T, if you are moving too slowly when boosted, you will rubberband", unit = "°") + private val upPitch by setting("Up Pitch", 36f, 0f..60f, 2f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "If you are moving up or you are pressing space, this pitch will be used", unit = "°") + private val downPitch by setting("Down Pitch", 35f, 0f..40f, 1f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Pitch used when you are moving down", unit = "°") private val controlSpeed by setting("Control Speed", true, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }, description = "Enable to set pitch controls based on your speed") - private val speedThreshold by setting("Speed Threshold", 43, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, use the Up Pitch value") - private val slowPercentage by setting("Slow Percentage", 45, 1..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "Rotates the pitch into the Down Pitch value. Low percents rotate fast, high percents rotate slow") + private val speedThreshold by setting("Speed Threshold", 43, 5..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "If you are going faster then the speed threshold, the Up Pitch value will be used", unit = " MPS") + private val pitchPercentPath by setting("Pitch Percent Path", 60, 1..100, 1, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS && controlSpeed }, description = "Rotates the pitch into the Down Pitch value. Low percents rotate faster, high percents rotate slower", unit = "%") /* End of Mode Settings */ @@ -282,9 +282,7 @@ object ElytraFlight : Module( if (!mc.isSingleplayer) mc.timer.tickLength = 200.0f /* Use timer to pause longer */ player.motionY = 0.0 } - else -> { - player.motionY = -0.2 - } + else -> player.motionY = -0.2 } } } @@ -486,16 +484,17 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { - var playerSpeedCal = if (speedList.isEmpty()) 0.0 else speedList.sum() / speedList.size //This is the only way I found to get the player speed - var speedPercentOfMax = (playerSpeedCal/speedThreshold*100).toFloat() //This is used to calulate the percent of the max speed. 50 means 50% + var playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*(1000 / TimerManager.tickLength) //This is the player's speed + var speedPercentOfMax = playerSpeed/speedThreshold*100 //This is used to calulate the percent of the max speed. 50 means 50% packetPitch = when { world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch player.motionY > 0 || System.currentTimeMillis() < upPitchTimer || player.movementInput.jump -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch - controlSpeed && playerSpeedCal > speedThreshold -> { //If controlSpeed is enabled and the speed is over the speedThreshold, then.... + controlSpeed && playerSpeed > speedThreshold -> { //If controlSpeed is enabled and the speed is over the speedThreshold, then.... upPitchTimer = System.currentTimeMillis() + 1000 //Set upPitchTimer for 1 second -upPitch} //Use -upPitch - controlSpeed && speedPercentOfMax < slowPercentage -> speedPercentOfMax/slowPercentage*downPitch //Simple expression that slowly curves the pitch into downPitch - else -> downPitch} // If none of the other conditions are met, use downPitch + controlSpeed && speedPercentOfMax < pitchPercentPath -> speedPercentOfMax/pitchPercentPath*downPitch //Simple expression that slowly curves the pitch into downPitch + else -> downPitch // If none of the other conditions are met, use downPitch + } } fun shouldSwing(): Boolean { From e8af92d972c1c4eaaa2fc4bf1af32d7e22f0f19b Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Mon, 29 May 2023 20:55:58 -0500 Subject: [PATCH 5/8] fixed toggles and added conditional to AutoOffhand --- .../module/modules/combat/AutoOffhand.kt | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index ffdec99d9..1936ec539 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -34,38 +34,39 @@ object AutoOffhand : Module( description = "Manages item in your offhand", category = Category.COMBAT ) { + // General + private val switchMessage by setting("Switch Message", true) + private val priority by setting("Priority", Priority.HOTBAR) + private val conditional by setting("Conditional", false) private val type by setting("Type", Type.TOTEM) // Totem - private val hpThreshold by setting("Hp Threshold", 5f, 1f..36f, 0.5f, { type == Type.TOTEM }) + private val offhandTotem by setting("Offhand Totem", true, { type == Type.TOTEM }) private val bindTotem by setting("Bind Totem", Bind(), { type == Type.TOTEM }) - private val checkDamage by setting("Check Damage", true, { type == Type.TOTEM }) - private val mob by setting("Mob", true, { type == Type.TOTEM && checkDamage }) - private val player by setting("Player", true, { type == Type.TOTEM && checkDamage }) - private val crystal by setting("Crystal", true, { type == Type.TOTEM && checkDamage }) - private val falling by setting("Falling", true, { type == Type.TOTEM && checkDamage }) + private val hpThreshold by setting("Hp Threshold", 5f, 1f..36f, 0.5f, { type == Type.TOTEM && offhandTotem && conditional }) + private val checkDamage by setting("Check Damage", true, { type == Type.TOTEM && offhandTotem && conditional }) + private val mob by setting("Mob", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional }) + private val player by setting("Player", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional }) + private val crystal by setting("Crystal", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional }) + private val falling by setting("Falling", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional }) // Gapple private val offhandGapple by setting("Offhand Gapple", false, { type == Type.GAPPLE }) - private val bindGapple by setting("Bind Gapple", Bind(), { type == Type.GAPPLE && offhandGapple }) - private val checkAuraG by setting("Check Aura G", true, { type == Type.GAPPLE && offhandGapple }) - private val checkWeaponG by setting("Check Weapon G", false, { type == Type.GAPPLE && offhandGapple }) - private val checkCAGapple by setting("Check CrystalAura G", true, { type == Type.GAPPLE && offhandGapple && !offhandCrystal }) + private val bindGapple by setting("Bind Gapple", Bind(), { type == Type.GAPPLE }) + private val checkAuraG by setting("Check Aura G", true, { type == Type.GAPPLE && offhandGapple && conditional }) + private val checkWeaponG by setting("Check Weapon G", false, { type == Type.GAPPLE && offhandGapple && conditional }) + private val checkCAGapple by setting("Check CrystalAura G", true, { type == Type.GAPPLE && offhandGapple && !offhandCrystal && conditional }) // Strength private val offhandStrength by setting("Offhand Strength", false, { type == Type.STRENGTH }) - private val bindStrength by setting("Bind Strength", Bind(), { type == Type.STRENGTH && offhandStrength }) - private val checkAuraS by setting("Check Aura S", true, { type == Type.STRENGTH && offhandStrength }) - private val checkWeaponS by setting("Check Weapon S", false, { type == Type.STRENGTH && offhandStrength }) + private val bindStrength by setting("Bind Strength", Bind(), { type == Type.STRENGTH }) + private val checkAuraS by setting("Check Aura S", true, { type == Type.STRENGTH && offhandStrength && conditional }) + private val checkWeaponS by setting("Check Weapon S", false, { type == Type.STRENGTH && offhandStrength && conditional }) // Crystal private val offhandCrystal by setting("Offhand Crystal", false, { type == Type.CRYSTAL }) - private val bindCrystal by setting("Bind Crystal", Bind(), { type == Type.CRYSTAL && offhandCrystal }) - private val checkCACrystal by setting("Check Crystal Aura C", false, { type == Type.CRYSTAL && offhandCrystal }) - - // General - private val priority by setting("Priority", Priority.HOTBAR) - private val switchMessage by setting("Switch Message", true) + private val bindCrystal by setting("Bind Crystal", Bind(), { type == Type.CRYSTAL }) + private val checkCACrystal by setting("Check Crystal Aura C", false, { type == Type.CRYSTAL && offhandCrystal && conditional }) // Represents the remaining number of items of type AutoOffhandType in the inventory private var hudInfo = "" @@ -100,7 +101,7 @@ object AutoOffhand : Module( updateDamage() - switchToType(getType(), true) + if (player.heldItemOffhand.isEmpty) switchToType(getType()) hudInfo = player.allSlots.countByStack { type.filter(it) }.toString() } @@ -113,26 +114,27 @@ object AutoOffhand : Module( checkStrength() -> Type.STRENGTH checkGapple() -> Type.GAPPLE checkCrystal() -> Type.CRYSTAL - player.heldItemOffhand.isEmpty -> Type.TOTEM else -> null } - private fun SafeClientEvent.checkTotem() = player.scaledHealth < hpThreshold - || (checkDamage && player.scaledHealth - maxDamage < hpThreshold) + //The conditional code is difficult to read + private fun SafeClientEvent.checkTotem() = offhandTotem && (!conditional || ( + player.scaledHealth < hpThreshold || + (checkDamage && player.scaledHealth - maxDamage < hpThreshold))) - private fun SafeClientEvent.checkGapple() = offhandGapple - && (checkAuraG && CombatManager.isActiveAndTopPriority(KillAura) - || checkWeaponG && player.heldItemMainhand.item.isWeapon - || (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura)) + private fun SafeClientEvent.checkGapple() = offhandGapple && (!conditional || ( + (checkAuraG && CombatManager.isActiveAndTopPriority(KillAura) || + checkWeaponG && player.heldItemMainhand.item.isWeapon || + (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura)))) - private fun checkCrystal() = offhandCrystal - && checkCACrystal && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura) + private fun checkCrystal() = offhandCrystal && (!conditional || ( + checkCACrystal && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura))) - private fun SafeClientEvent.checkStrength() = offhandStrength - && !player.isPotionActive(MobEffects.STRENGTH) - && player.inventoryContainer.inventory.any(Type.STRENGTH.filter) - && (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura) - || checkWeaponS && player.heldItemMainhand.item.isWeapon) + private fun SafeClientEvent.checkStrength() = offhandStrength && (!conditional || ( + !player.isPotionActive(MobEffects.STRENGTH) && + player.inventoryContainer.inventory.any(Type.STRENGTH.filter) && + (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura) || + checkWeaponS && player.heldItemMainhand.item.isWeapon))) private fun SafeClientEvent.switchToType(typeOriginal: Type?, alternativeType: Boolean = false) { // First check for whether player is holding the right item already or not @@ -153,11 +155,8 @@ object AutoOffhand : Module( private fun SafeClientEvent.getItemSlot(type: Type, attempts: Int): Pair? = getSlot(type)?.to(type) - ?: if (attempts > 1) { - getItemSlot(type.next(), attempts - 1) - } else { - null - } + ?: if (attempts > 1) {getItemSlot(type.next(), attempts - 1)} + else null private fun SafeClientEvent.getSlot(type: Type): Slot? { return player.offhandSlot.takeIf(filter(type)) @@ -175,9 +174,7 @@ object AutoOffhand : Module( private fun List.findItemByType(type: Type) = find(filter(type)) - private fun filter(type: Type) = { it: Slot -> - type.filter(it.stack) - } + private fun filter(type: Type) = { it: Slot -> type.filter(it.stack)} private fun SafeClientEvent.updateDamage() { maxDamage = 0f From e0c2b7e23235c8cce861fa00dc7279698f34982b Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Tue, 30 May 2023 08:11:00 -0500 Subject: [PATCH 6/8] Added Align Coords to Coordinates --- .../client/gui/hudgui/elements/world/Coordinates.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt index 7031a56c1..fcb0990a8 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt @@ -16,8 +16,9 @@ internal object Coordinates : LabelHud( private val showY by setting("Show Y", true) private val showZ by setting("Show Z", true) private val showNetherOverworld by setting("Show Nether/Overworld", true) - private val decimalPlaces by setting("Decimal Places", 1, 0..4, 1) + private val decimalPlaces by setting("Decimal Places", 0, 0..4, 1) private val thousandsSeparator by setting("Thousands Separator", false) + private val alignCoords by setting("Align Coords", true, description = "Align your coords to the center of the block") private val netherToOverworld = Vec3d(8.0, 1.0, 8.0) private val overworldToNether = Vec3d(0.125, 1.0, 0.125) @@ -43,9 +44,13 @@ internal object Coordinates : LabelHud( } private fun getFormattedCoords(pos: Vec3d): TextComponent.TextElement { - val x = roundOrInt(pos.x) + val alignValue = when { + alignCoords -> 0.5f + else -> 0.0f + } + val x = roundOrInt(pos.x-alignValue) val y = roundOrInt(pos.y) - val z = roundOrInt(pos.z) + val z = roundOrInt(pos.z-alignValue) return StringBuilder().run { if (showX) append(x) if (showY) appendWithComma(y) @@ -61,5 +66,4 @@ internal object Coordinates : LabelHud( } private fun StringBuilder.appendWithComma(string: String) = append(if (length > 0) ", $string" else string) - } \ No newline at end of file From 353b6467fdacaf7de13a606c096abeb774fb7d33 Mon Sep 17 00:00:00 2001 From: nickcat325 Date: Sun, 11 Jun 2023 23:32:30 -0500 Subject: [PATCH 7/8] Efly can be used with timer --- .../com/lambda/client/command/commands/ConfigCommand.kt | 6 ++---- .../lambda/client/module/modules/movement/ElytraFlight.kt | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt index 16a42c2dd..2f73ce084 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt @@ -57,7 +57,7 @@ object ConfigCommand : ClientCommand( } } - literal("set") { + literal("set", "load") { string("name") { nameArg -> execute("Change preset") { configTypeArg.value.setPreset(nameArg.value) @@ -137,9 +137,7 @@ object ConfigCommand : ClientCommand( return if (ip == null || mc.isIntegratedServerRunning) { MessageSendHelper.sendWarningMessage("You are not in a server!") null - } else { - ip - } + } else ip } private fun IExecuteEvent.confirm(): Boolean { diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 8f547f2f1..ea8548512 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -5,7 +5,6 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket -import com.lambda.client.manager.managers.TimerManager import com.lambda.client.mixin.extension.boostedEntity import com.lambda.client.mixin.extension.playerPosLookPitch import com.lambda.client.mixin.extension.tickLength @@ -484,7 +483,7 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { - var playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*(1000 / TimerManager.tickLength) //This is the player's speed + var playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*20 //This is the player's speed var speedPercentOfMax = playerSpeed/speedThreshold*100 //This is used to calulate the percent of the max speed. 50 means 50% packetPitch = when { world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch From a769992161c1f7b579c370a0a26a76b9c5a7c201 Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 8 Aug 2023 03:25:54 +0200 Subject: [PATCH 8/8] Minor style changes --- .../gui/hudgui/elements/world/Coordinates.kt | 11 ++---- .../module/modules/combat/AutoOffhand.kt | 37 ++++++++++--------- .../module/modules/movement/ElytraFlight.kt | 23 +++++++----- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt index fcb0990a8..f4dcdad5e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt @@ -16,9 +16,8 @@ internal object Coordinates : LabelHud( private val showY by setting("Show Y", true) private val showZ by setting("Show Z", true) private val showNetherOverworld by setting("Show Nether/Overworld", true) - private val decimalPlaces by setting("Decimal Places", 0, 0..4, 1) + private val decimalPlaces by setting("Decimal Places", 1, 0..4, 1) private val thousandsSeparator by setting("Thousands Separator", false) - private val alignCoords by setting("Align Coords", true, description = "Align your coords to the center of the block") private val netherToOverworld = Vec3d(8.0, 1.0, 8.0) private val overworldToNether = Vec3d(0.125, 1.0, 0.125) @@ -44,13 +43,9 @@ internal object Coordinates : LabelHud( } private fun getFormattedCoords(pos: Vec3d): TextComponent.TextElement { - val alignValue = when { - alignCoords -> 0.5f - else -> 0.0f - } - val x = roundOrInt(pos.x-alignValue) + val x = roundOrInt(pos.x) val y = roundOrInt(pos.y) - val z = roundOrInt(pos.z-alignValue) + val z = roundOrInt(pos.z) return StringBuilder().run { if (showX) append(x) if (showY) appendWithComma(y) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 1936ec539..531ded5c0 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -117,24 +117,24 @@ object AutoOffhand : Module( else -> null } - //The conditional code is difficult to read - private fun SafeClientEvent.checkTotem() = offhandTotem && (!conditional || ( - player.scaledHealth < hpThreshold || - (checkDamage && player.scaledHealth - maxDamage < hpThreshold))) + private fun SafeClientEvent.checkTotem() = offhandTotem + && (!conditional || (player.scaledHealth < hpThreshold + || (checkDamage && player.scaledHealth - maxDamage < hpThreshold))) - private fun SafeClientEvent.checkGapple() = offhandGapple && (!conditional || ( - (checkAuraG && CombatManager.isActiveAndTopPriority(KillAura) || - checkWeaponG && player.heldItemMainhand.item.isWeapon || - (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura)))) + private fun SafeClientEvent.checkGapple() = offhandGapple + && (!conditional || ((checkAuraG && CombatManager.isActiveAndTopPriority(KillAura) + || checkWeaponG && player.heldItemMainhand.item.isWeapon + || (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura)))) - private fun checkCrystal() = offhandCrystal && (!conditional || ( - checkCACrystal && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura))) + private fun checkCrystal() = offhandCrystal + && (!conditional || (checkCACrystal && CrystalAura.isEnabled + && CombatManager.isOnTopPriority(CrystalAura))) - private fun SafeClientEvent.checkStrength() = offhandStrength && (!conditional || ( - !player.isPotionActive(MobEffects.STRENGTH) && - player.inventoryContainer.inventory.any(Type.STRENGTH.filter) && - (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura) || - checkWeaponS && player.heldItemMainhand.item.isWeapon))) + private fun SafeClientEvent.checkStrength() = offhandStrength + && (!conditional || (!player.isPotionActive(MobEffects.STRENGTH) + && player.inventoryContainer.inventory.any(Type.STRENGTH.filter) + && (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura) + || checkWeaponS && player.heldItemMainhand.item.isWeapon))) private fun SafeClientEvent.switchToType(typeOriginal: Type?, alternativeType: Boolean = false) { // First check for whether player is holding the right item already or not @@ -155,8 +155,9 @@ object AutoOffhand : Module( private fun SafeClientEvent.getItemSlot(type: Type, attempts: Int): Pair? = getSlot(type)?.to(type) - ?: if (attempts > 1) {getItemSlot(type.next(), attempts - 1)} - else null + ?: if (attempts > 1) { + getItemSlot(type.next(), attempts - 1) + } else null private fun SafeClientEvent.getSlot(type: Type): Slot? { return player.offhandSlot.takeIf(filter(type)) @@ -174,7 +175,7 @@ object AutoOffhand : Module( private fun List.findItemByType(type: Type) = find(filter(type)) - private fun filter(type: Type) = { it: Slot -> type.filter(it.stack)} + private fun filter(type: Type) = { it: Slot -> type.filter(it.stack) } private fun SafeClientEvent.updateDamage() { maxDamage = 0f diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index ea8548512..900479a94 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -483,16 +483,21 @@ object ElytraFlight : Module( } private fun SafeClientEvent.vanillaMode() { - var playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*20 //This is the player's speed - var speedPercentOfMax = playerSpeed/speedThreshold*100 //This is used to calulate the percent of the max speed. 50 means 50% + val playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*20 // This is the player's speed + val speedPercentOfMax = playerSpeed/speedThreshold*100 // This is used to calculate the percent of the max speed. 50 means 50% packetPitch = when { - world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch //If the player is boosted with a firework, use -rocketPitch - player.motionY > 0 || System.currentTimeMillis() < upPitchTimer || player.movementInput.jump -> -upPitch //If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch - controlSpeed && playerSpeed > speedThreshold -> { //If controlSpeed is enabled and the speed is over the speedThreshold, then.... - upPitchTimer = System.currentTimeMillis() + 1000 //Set upPitchTimer for 1 second - -upPitch} //Use -upPitch - controlSpeed && speedPercentOfMax < pitchPercentPath -> speedPercentOfMax/pitchPercentPath*downPitch //Simple expression that slowly curves the pitch into downPitch - else -> downPitch // If none of the other conditions are met, use downPitch + // If the player is boosted with a firework, use -rocketPitch + world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch + // If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch + player.motionY > 0 || System.currentTimeMillis() < upPitchTimer || player.movementInput.jump -> -upPitch + // If controlSpeed is enabled and the speed is over the speedThreshold, then.... + controlSpeed && playerSpeed > speedThreshold -> { + upPitchTimer = System.currentTimeMillis() + 1000 // Set upPitchTimer for 1 second + -upPitch} // Use -upPitch + // Simple expression that slowly curves the pitch into downPitch + controlSpeed && speedPercentOfMax < pitchPercentPath -> speedPercentOfMax/pitchPercentPath*downPitch + // If none of the other conditions are met, use downPitch + else -> downPitch } }