Skip to content

Commit fe3a4a0

Browse files
author
Doogie13
committed
Add Boost to Speed, settings edited on other modes to be better compliant with NCP
1 parent 4f04955 commit fe3a4a0

File tree

1 file changed

+76
-6
lines changed
  • src/main/kotlin/com/lambda/client/module/modules/movement

1 file changed

+76
-6
lines changed

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

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.lambda.client.module.modules.movement
22

33
import com.lambda.client.event.SafeClientEvent
4+
import com.lambda.client.event.events.PacketEvent
45
import com.lambda.client.event.events.PlayerMoveEvent
56
import com.lambda.client.event.events.PlayerTravelEvent
67
import com.lambda.client.manager.managers.TimerManager.modifyTimer
78
import com.lambda.client.manager.managers.TimerManager.resetTimer
8-
import com.lambda.client.mixin.extension.isInWeb
9+
import com.lambda.client.mixin.extension.*
910
import com.lambda.client.module.Category
1011
import com.lambda.client.module.Module
1112
import com.lambda.client.module.modules.player.AutoEat
@@ -23,8 +24,10 @@ import com.lambda.client.util.TimeUnit
2324
import com.lambda.client.util.threads.runSafe
2425
import com.lambda.client.util.threads.safeListener
2526
import net.minecraft.client.settings.KeyBinding
27+
import net.minecraft.network.play.client.CPacketPlayer
2628
import net.minecraftforge.fml.common.gameevent.TickEvent
2729
import java.lang.Double.max
30+
import java.lang.Double.min
2831
import kotlin.math.cos
2932
import kotlin.math.sin
3033

@@ -38,19 +41,22 @@ object Speed : Module(
3841
val mode by setting("Mode", SpeedMode.STRAFE)
3942

4043
// strafe settings
41-
private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.029f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE })
44+
private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE })
4245
private val strafeTimerBoost by setting("Timer Boost", true, { mode == SpeedMode.STRAFE })
4346
private val strafeAutoJump by setting("Auto Jump", true, { mode == SpeedMode.STRAFE })
4447
private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE })
4548
private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE })
4649

4750
// onGround settings
4851
private val onGroundTimer by setting("Timer", true, { mode == SpeedMode.ONGROUND })
49-
private val onGroundTimerSpeed by setting("Timer Speed", 1.29f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer })
52+
private val onGroundTimerSpeed by setting("Timer Speed", 1.088f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer })
5053
private val onGroundSpeed by setting("Speed", 1.31f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND })
5154
private val onGroundSprint by setting("Sprint", true, { mode == SpeedMode.ONGROUND })
5255
private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND })
5356

57+
// boost settings
58+
private val boostSpeed by setting("Boost Speed", .61, 0.28..1.0, 0.01, {mode == SpeedMode.BOOST})
59+
5460
// Strafe Mode
5561
private var jumpTicks = 0
5662
private val strafeTimer = TickTimer(TimeUnit.TICKS)
@@ -60,8 +66,10 @@ object Speed : Module(
6066

6167
private var currentMode = mode
6268

69+
private var spoofUp = true
70+
6371
enum class SpeedMode {
64-
STRAFE, ONGROUND
72+
STRAFE, ONGROUND, BOOST
6573
}
6674

6775
init {
@@ -105,13 +113,49 @@ object Speed : Module(
105113
if (shouldOnGround()) onGround()
106114
else resetTimer()
107115
}
116+
SpeedMode.BOOST -> {
117+
118+
handleBoost(it)
119+
120+
}
108121
}
109122
}
123+
124+
safeListener<PacketEvent.Send> {
125+
126+
if (mode == SpeedMode.BOOST) {
127+
128+
if (it.packet is CPacketPlayer) {
129+
130+
if (it.packet.playerMoving && spoofUp) {
131+
132+
it.packet.playerIsOnGround = false
133+
134+
it.packet.playerY =
135+
(
136+
if (
137+
world.collidesWithAnyBlock(
138+
player.entityBoundingBox
139+
.offset(it.packet.playerX, it.packet.playerY, it.packet.playerZ)
140+
.offset(0.0,.42,0.0))
141+
)
142+
.2
143+
else
144+
.42
145+
) + player.posY
146+
}
147+
}
148+
149+
}
150+
151+
}
152+
110153
}
111154

112155
private fun SafeClientEvent.strafe() {
113156
player.jumpMovementFactor = strafeAirSpeedBoost
114-
if (strafeTimerBoost) modifyTimer(45.87155914306640625f)
157+
// slightly slower timer speed bypasses better (1.088)
158+
if (strafeTimerBoost) modifyTimer(45.955883f)
115159
if ((Step.isDisabled || !player.collidedHorizontally) && strafeAutoJump) jump()
116160

117161
strafeTimer.reset()
@@ -168,4 +212,30 @@ object Speed : Module(
168212

169213
jumpTicks--
170214
}
171-
}
215+
216+
private fun SafeClientEvent.handleBoost(event : PlayerMoveEvent) {
217+
218+
spoofUp = !spoofUp && player.onGround
219+
220+
if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f) {
221+
modifyTimer(50f)
222+
spoofUp = false
223+
return
224+
}
225+
226+
modifyTimer(45.955883f)
227+
228+
val speed = if (spoofUp) boostSpeed else .2873
229+
230+
val yaw = calcMoveYaw()
231+
event.x = -sin(yaw) * speed
232+
if (spoofUp) {
233+
event.y = min(0.0, event.y)
234+
} else if (player.movementInput.jump) {
235+
jump()
236+
}
237+
event.z = cos(yaw) * speed
238+
239+
}
240+
241+
}

0 commit comments

Comments
 (0)