Skip to content

Commit 821a71f

Browse files
authored
Merge pull request #540 from nickcat325/master
Vanilla elytra flight rewrite and AutoOffhand changes
2 parents e1b54c4 + 204a936 commit 821a71f

File tree

4 files changed

+57
-57
lines changed

4 files changed

+57
-57
lines changed

src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object ConfigCommand : ClientCommand(
5757
}
5858
}
5959

60-
literal("set") {
60+
literal("set", "load") {
6161
string("name") { nameArg ->
6262
execute("Change preset") {
6363
configTypeArg.value.setPreset(nameArg.value)
@@ -137,9 +137,7 @@ object ConfigCommand : ClientCommand(
137137
return if (ip == null || mc.isIntegratedServerRunning) {
138138
MessageSendHelper.sendWarningMessage("You are not in a server!")
139139
null
140-
} else {
141-
ip
142-
}
140+
} else ip
143141
}
144142

145143
private fun IExecuteEvent.confirm(): Boolean {

src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,4 @@ internal object Coordinates : LabelHud(
7070
}
7171

7272
private fun StringBuilder.appendWithComma(string: String) = append(if (isNotEmpty()) ", $string" else string)
73-
7473
}

src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,39 @@ object AutoOffhand : Module(
3434
description = "Manages item in your offhand",
3535
category = Category.COMBAT
3636
) {
37+
// General
38+
private val switchMessage by setting("Switch Message", true)
39+
private val priority by setting("Priority", Priority.HOTBAR)
40+
private val conditional by setting("Conditional", false)
3741
private val type by setting("Type", Type.TOTEM)
3842

3943
// Totem
40-
private val hpThreshold by setting("Hp Threshold", 5f, 1f..36f, 0.5f, { type == Type.TOTEM })
44+
private val offhandTotem by setting("Offhand Totem", true, { type == Type.TOTEM })
4145
private val bindTotem by setting("Bind Totem", Bind(), { type == Type.TOTEM })
42-
private val checkDamage by setting("Check Damage", true, { type == Type.TOTEM })
43-
private val mob by setting("Mob", true, { type == Type.TOTEM && checkDamage })
44-
private val player by setting("Player", true, { type == Type.TOTEM && checkDamage })
45-
private val crystal by setting("Crystal", true, { type == Type.TOTEM && checkDamage })
46-
private val falling by setting("Falling", true, { type == Type.TOTEM && checkDamage })
46+
private val hpThreshold by setting("Hp Threshold", 5f, 1f..36f, 0.5f, { type == Type.TOTEM && offhandTotem && conditional })
47+
private val checkDamage by setting("Check Damage", true, { type == Type.TOTEM && offhandTotem && conditional })
48+
private val mob by setting("Mob", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional })
49+
private val player by setting("Player", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional })
50+
private val crystal by setting("Crystal", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional })
51+
private val falling by setting("Falling", true, { type == Type.TOTEM && offhandTotem && checkDamage && conditional })
4752

4853
// Gapple
4954
private val offhandGapple by setting("Offhand Gapple", false, { type == Type.GAPPLE })
50-
private val bindGapple by setting("Bind Gapple", Bind(), { type == Type.GAPPLE && offhandGapple })
51-
private val checkAuraG by setting("Check Aura G", true, { type == Type.GAPPLE && offhandGapple })
52-
private val checkWeaponG by setting("Check Weapon G", false, { type == Type.GAPPLE && offhandGapple })
53-
private val checkCAGapple by setting("Check CrystalAura G", true, { type == Type.GAPPLE && offhandGapple && !offhandCrystal })
55+
private val bindGapple by setting("Bind Gapple", Bind(), { type == Type.GAPPLE })
56+
private val checkAuraG by setting("Check Aura G", true, { type == Type.GAPPLE && offhandGapple && conditional })
57+
private val checkWeaponG by setting("Check Weapon G", false, { type == Type.GAPPLE && offhandGapple && conditional })
58+
private val checkCAGapple by setting("Check CrystalAura G", true, { type == Type.GAPPLE && offhandGapple && !offhandCrystal && conditional })
5459

5560
// Strength
5661
private val offhandStrength by setting("Offhand Strength", false, { type == Type.STRENGTH })
57-
private val bindStrength by setting("Bind Strength", Bind(), { type == Type.STRENGTH && offhandStrength })
58-
private val checkAuraS by setting("Check Aura S", true, { type == Type.STRENGTH && offhandStrength })
59-
private val checkWeaponS by setting("Check Weapon S", false, { type == Type.STRENGTH && offhandStrength })
62+
private val bindStrength by setting("Bind Strength", Bind(), { type == Type.STRENGTH })
63+
private val checkAuraS by setting("Check Aura S", true, { type == Type.STRENGTH && offhandStrength && conditional })
64+
private val checkWeaponS by setting("Check Weapon S", false, { type == Type.STRENGTH && offhandStrength && conditional })
6065

6166
// Crystal
6267
private val offhandCrystal by setting("Offhand Crystal", false, { type == Type.CRYSTAL })
63-
private val bindCrystal by setting("Bind Crystal", Bind(), { type == Type.CRYSTAL && offhandCrystal })
64-
private val checkCACrystal by setting("Check Crystal Aura C", false, { type == Type.CRYSTAL && offhandCrystal })
65-
66-
// General
67-
private val priority by setting("Priority", Priority.HOTBAR)
68-
private val switchMessage by setting("Switch Message", true)
68+
private val bindCrystal by setting("Bind Crystal", Bind(), { type == Type.CRYSTAL })
69+
private val checkCACrystal by setting("Check Crystal Aura C", false, { type == Type.CRYSTAL && offhandCrystal && conditional })
6970

7071
// Represents the remaining number of items of type AutoOffhandType in the inventory
7172
private var hudInfo = ""
@@ -100,7 +101,7 @@ object AutoOffhand : Module(
100101

101102
updateDamage()
102103

103-
switchToType(getType(), true)
104+
if (player.heldItemOffhand.isEmpty) switchToType(getType())
104105

105106
hudInfo = player.allSlots.countByStack { type.filter(it) }.toString()
106107
}
@@ -113,26 +114,27 @@ object AutoOffhand : Module(
113114
checkStrength() -> Type.STRENGTH
114115
checkGapple() -> Type.GAPPLE
115116
checkCrystal() -> Type.CRYSTAL
116-
player.heldItemOffhand.isEmpty -> Type.TOTEM
117117
else -> null
118118
}
119119

120-
private fun SafeClientEvent.checkTotem() = player.scaledHealth < hpThreshold
121-
|| (checkDamage && player.scaledHealth - maxDamage < hpThreshold)
120+
private fun SafeClientEvent.checkTotem() = offhandTotem
121+
&& (!conditional || (player.scaledHealth < hpThreshold
122+
|| (checkDamage && player.scaledHealth - maxDamage < hpThreshold)))
122123

123124
private fun SafeClientEvent.checkGapple() = offhandGapple
124-
&& (checkAuraG && CombatManager.isActiveAndTopPriority(KillAura)
125+
&& (!conditional || ((checkAuraG && CombatManager.isActiveAndTopPriority(KillAura)
125126
|| checkWeaponG && player.heldItemMainhand.item.isWeapon
126-
|| (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura))
127+
|| (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura))))
127128

128129
private fun checkCrystal() = offhandCrystal
129-
&& checkCACrystal && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura)
130+
&& (!conditional || (checkCACrystal && CrystalAura.isEnabled
131+
&& CombatManager.isOnTopPriority(CrystalAura)))
130132

131133
private fun SafeClientEvent.checkStrength() = offhandStrength
132-
&& !player.isPotionActive(MobEffects.STRENGTH)
134+
&& (!conditional || (!player.isPotionActive(MobEffects.STRENGTH)
133135
&& player.inventoryContainer.inventory.any(Type.STRENGTH.filter)
134136
&& (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura)
135-
|| checkWeaponS && player.heldItemMainhand.item.isWeapon)
137+
|| checkWeaponS && player.heldItemMainhand.item.isWeapon)))
136138

137139
private fun SafeClientEvent.switchToType(typeOriginal: Type?, alternativeType: Boolean = false) {
138140
// First check for whether player is holding the right item already or not
@@ -155,9 +157,7 @@ object AutoOffhand : Module(
155157
getSlot(type)?.to(type)
156158
?: if (attempts > 1) {
157159
getItemSlot(type.next(), attempts - 1)
158-
} else {
159-
null
160-
}
160+
} else null
161161

162162
private fun SafeClientEvent.getSlot(type: Type): Slot? {
163163
return player.offhandSlot.takeIf(filter(type))
@@ -175,9 +175,7 @@ object AutoOffhand : Module(
175175
private fun List<Slot>.findItemByType(type: Type) =
176176
find(filter(type))
177177

178-
private fun filter(type: Type) = { it: Slot ->
179-
type.filter(it.stack)
180-
}
178+
private fun filter(type: Type) = { it: Slot -> type.filter(it.stack) }
181179

182180
private fun SafeClientEvent.updateDamage() {
183181
maxDamage = 0f
@@ -189,12 +187,8 @@ object AutoOffhand : Module(
189187
if (player.getDistance(entity) > 10.0f) continue
190188

191189
when {
192-
mob && entity is EntityMob -> {
193-
maxDamage = max(calcDamageFromMob(entity), maxDamage)
194-
}
195-
this@AutoOffhand.player && entity is EntityPlayer -> {
196-
maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage)
197-
}
190+
mob && entity is EntityMob -> maxDamage = max(calcDamageFromMob(entity), maxDamage)
191+
this@AutoOffhand.player && entity is EntityPlayer -> maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage)
198192
crystal && entity is EntityEnderCrystal -> {
199193
val damage = CombatManager.crystalMap[entity] ?: continue
200194
maxDamage = max(damage.selfDamage, maxDamage)

src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ object ElytraFlight : Module(
103103

104104

105105
/* Vanilla */
106-
private val upPitch by setting("Up Pitch", 30f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS })
107-
private val downPitch by setting("Down Pitch", 0f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS })
108-
private val rocketPitch by setting("Rocket Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS })
106+
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 = "°")
107+
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 = "°")
108+
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 = "°")
109+
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")
110+
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")
111+
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 = "%")
109112

110113
/* Fireworks */
111114
private val fireworkUseMode by setting("Firework Use Mode", FireworkUseMode.SPEED, { mode.value == ElytraFlightMode.FIREWORKS && page == Page.MODE_SETTINGS })
@@ -151,8 +154,7 @@ object ElytraFlight : Module(
151154
private var boostingTick = 0
152155

153156
/* Vanilla mode state */
154-
private var firstY = 0.0
155-
private var secondY = 0.0
157+
private var upPitchTimer: Long = 0
156158

157159
/* Fireworks mode state */
158160
private var fireworkTickTimer: TickTimer = TickTimer(TimeUnit.TICKS)
@@ -306,9 +308,7 @@ object ElytraFlight : Module(
306308
if (!mc.isSingleplayer) mc.timer.tickLength = 200.0f /* Use timer to pause longer */
307309
player.motionY = 0.0
308310
}
309-
else -> {
310-
player.motionY = -0.2
311-
}
311+
else -> player.motionY = -0.2
312312
}
313313
}
314314
}
@@ -529,13 +529,22 @@ object ElytraFlight : Module(
529529
}
530530

531531
private fun SafeClientEvent.vanillaMode() {
532-
secondY = player.posY
532+
val playerSpeed = (sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)).toFloat()*20 // This is the player's speed
533+
val speedPercentOfMax = playerSpeed/speedThreshold*100 // This is used to calculate the percent of the max speed. 50 means 50%
533534
packetPitch = when {
535+
// If the player is boosted with a firework, use -rocketPitch
534536
world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch
535-
firstY - secondY > 0 -> downPitch
536-
else -> -upPitch
537+
// If the player is moving up, the player is pressing space, or upPitchTimer is still going, use -upPitch
538+
player.motionY > 0 || System.currentTimeMillis() < upPitchTimer || player.movementInput.jump -> -upPitch
539+
// If controlSpeed is enabled and the speed is over the speedThreshold, then....
540+
controlSpeed && playerSpeed > speedThreshold -> {
541+
upPitchTimer = System.currentTimeMillis() + 1000 // Set upPitchTimer for 1 second
542+
-upPitch} // Use -upPitch
543+
// Simple expression that slowly curves the pitch into downPitch
544+
controlSpeed && speedPercentOfMax < pitchPercentPath -> speedPercentOfMax/pitchPercentPath*downPitch
545+
// If none of the other conditions are met, use downPitch
546+
else -> downPitch
537547
}
538-
firstY = player.posY
539548
}
540549

541550
private fun SafeClientEvent.fireworksMode() {

0 commit comments

Comments
 (0)