Skip to content

Commit 89b9d72

Browse files
committed
fix launching forward when moving from still with an active firework
1 parent a7e1245 commit 89b9d72

3 files changed

Lines changed: 47 additions & 33 deletions

File tree

src/main/kotlin/com/lambda/interaction/managers/rotating/RotationRequest.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ interface IRotationRequest : Automated {
6767
override val done
6868
get() =
6969
runSafe {
70-
val delta = (if (BaritoneHandler.isActive) player.rotation else RotationManager.activeRotation)
71-
.yaw - (yaw.value ?: return@runSafe false)
70+
val rot =
71+
if (BaritoneHandler.isActive) player.rotation
72+
else RotationManager.activeRotation
73+
val delta = rot.yaw - (yaw.value ?: return@runSafe false)
7274
val wrappedDelta = ((delta + 180) % 360 + 360) % 360 - 180
7375
abs(wrappedDelta) <= 0.001
7476
} == true
@@ -92,8 +94,10 @@ interface IRotationRequest : Automated {
9294
override val done
9395
get() =
9496
runSafe {
95-
abs((if (BaritoneHandler.isActive) player.rotation else RotationManager.activeRotation)
96-
.pitch - (pitch.value ?: return@runSafe false)) <= 0.001
97+
val rot =
98+
if (BaritoneHandler.isActive) player.rotation
99+
else RotationManager.activeRotation
100+
abs(rot.pitch - (pitch.value ?: return@runSafe false)) <= 0.001
97101
} == true
98102

99103
override fun dist(rotation: Rotation): Double {
@@ -117,8 +121,10 @@ interface IRotationRequest : Automated {
117121
override val done
118122
get() =
119123
runSafe {
120-
(if (BaritoneHandler.isActive) player.rotation else RotationManager.activeRotation)
121-
.dist(rotation.value ?: return@runSafe false) <= 0.001
124+
val rot =
125+
if (BaritoneHandler.isActive) player.rotation
126+
else RotationManager.activeRotation
127+
rot.dist(rotation.value ?: return@runSafe false) <= 0.001
122128
} == true
123129

124130
override fun dist(rotation: Rotation) =
@@ -204,4 +210,4 @@ interface IRotationRequest : Automated {
204210
}
205211
}
206212
}
207-
}
213+
}

src/main/kotlin/com/lambda/module/modules/movement/elytrafly/ElytraFly.kt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ object ElytraFly : Module(
5858
private val boostSpeed by setting("Boost", 0.0, 0.0..0.5, 0.005, description = "Speed to add when flying")
5959
private val rocketSpeed by setting("Rocket Speed", 1.0, 0.0..2.0, 0.01, description = "Speed multiplier that the rocket gives you")
6060
private val angledRocketBoost by setting("Angled Rocket Boost", true, description = "Automatically scale the firework rocket boost based on your pitch angle")
61-
private val maxAngledBoost by setting("Max Angled Boost", 0.75, 0.0..5.0, 0.05, description = "Additional speed added on top of your base rocket speed when flying diagonally at exactly 45 degrees") { angledRocketBoost }
61+
private val maxAngledBoost by setting("Max Angled Boost", 0.75, 0.0..5.0, 0.01, description = "Additional speed added on top of your base rocket speed when flying diagonally at exactly 45 degrees") { angledRocketBoost }
6262
private val mute by setting("Mute Elytra", false, "Mutes the elytra sound when gliding")
6363
@JvmStatic val fakeFly by setting("Fake Fly", false, "Rapidly swaps the chestplate and elytra to give the appearance the player is flying without an elytra. May also reduce durability loss")
6464

@@ -106,27 +106,28 @@ object ElytraFly : Module(
106106
}
107107

108108
@JvmStatic
109-
fun boostRocket() = runSafe {
110-
val rot = RotationManager.activeRotation
111-
112-
var targetSpeed = 1.5 * rocketSpeed
113-
if (angledRocketBoost) {
114-
val scale = sin(Math.toRadians(abs(rot.pitch) * 2.0))
115-
targetSpeed = (1.5 * rocketSpeed) + (maxAngledBoost * scale)
116-
}
109+
fun boostRocket() =
110+
runSafe {
111+
val rot = RotationManager.activeRotation
112+
113+
var targetSpeed = 1.5 * rocketSpeed
114+
if (angledRocketBoost) {
115+
val scale = sin(Math.toRadians(abs(rot.pitch) * 2.0))
116+
targetSpeed = (1.5 * rocketSpeed) + (maxAngledBoost * scale)
117+
}
117118

118-
val vec = Vec3d.fromPolar(rot.pitchF, rot.yawF)
119-
val velocity = player.velocity
119+
val vec = Vec3d.fromPolar(rot.pitchF, rot.yawF)
120+
val velocity = player.velocity
120121

121-
val d = targetSpeed
122-
val e = 0.1 * rocketSpeed
122+
val d = targetSpeed
123+
val e = 0.1 * rocketSpeed
123124

124-
player.velocity = velocity.add(
125-
vec.x * e + (vec.x * d - velocity.x) * 0.5,
126-
vec.y * e + (vec.y * d - velocity.y) * 0.5,
127-
vec.z * e + (vec.z * d - velocity.z) * 0.5
128-
)
129-
}
125+
player.velocity = velocity.add(
126+
vec.x * e + (vec.x * d - velocity.x) * 0.5,
127+
vec.y * e + (vec.y * d - velocity.y) * 0.5,
128+
vec.z * e + (vec.z * d - velocity.z) * 0.5
129+
)
130+
}
130131

131132
enum class FlyMode(private val elytraFlyGetter: () -> ElytraFlyMode) {
132133
Bounce({ bounceMode }),

src/main/kotlin/com/lambda/module/modules/movement/elytrafly/modes/GrimControlElytraFly.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class GrimControlElytraFly(
8989
if (mc.options.sneakKey.isPressed) vec = vec.add(Vec3d(0.0, -1.0, 0.0))
9090

9191
val prevStill = still
92-
still = (vec.lengthSquared() < 1e-4 || Freecam.isEnabled)
92+
still = vec.lengthSquared() < 1e-4 || Freecam.isEnabled
9393
if (still) moving = false
9494

9595
if (still && flipFlopMode != FlipFlopMode.Full) {
@@ -99,22 +99,29 @@ class GrimControlElytraFly(
9999
} else {
100100
if (fireworkTimer.timePassed(lastDuration.seconds - safetyMargin.seconds)) {
101101
val firework = findFirework()
102-
hasFirework = firework != null
103-
if (firework == null) return@listen
102+
if (firework == null) {
103+
hasFirework = false
104+
return@listen
105+
}
104106
lastDuration = (firework.get(DataComponentTypes.FIREWORKS)?.flightDuration ?: 1) * 0.5 + 0.5
105107
startFirework(inventory)
106108
fireworkTimer.reset()
109+
} else {
110+
hasFirework = hasFirework or player.hasFirework
107111
}
108112
}
109113

110114
if (still) {
111115
rotationRequest { rotation(if (flipFlop) 0.0 else 180.0, 0.0) }.submit()
112116
flipFlop = !flipFlop
113-
} else {
117+
return@listen
118+
}
119+
120+
val rot = vec.yawAndPitch
121+
rotationRequest { rotation(rot.y, rot.x) }.submit()
122+
if (hasFirework) {
114123
moving = true
115-
if (prevStill && !player.hasFirework) player.velocity = Vec3d.ZERO
116-
val rot = vec.yawAndPitch
117-
rotationRequest { rotation(rot.y, rot.x) }.submit()
124+
if (prevStill) player.velocity = Vec3d.ZERO
118125
}
119126
}
120127

0 commit comments

Comments
 (0)