@@ -4,10 +4,8 @@ import com.lambda.client.commons.interfaces.DisplayEnum
4
4
import com.lambda.client.event.SafeClientEvent
5
5
import com.lambda.client.event.events.PacketEvent
6
6
import com.lambda.client.event.events.PlayerMoveEvent
7
- import com.lambda.client.event.events.PlayerTravelEvent
8
7
import com.lambda.client.manager.managers.TimerManager.modifyTimer
9
8
import com.lambda.client.manager.managers.TimerManager.resetTimer
10
- import com.lambda.client.mixin.extension.isInWeb
11
9
import com.lambda.client.mixin.extension.playerY
12
10
import com.lambda.client.module.Category
13
11
import com.lambda.client.module.Module
@@ -16,13 +14,8 @@ import com.lambda.client.util.EntityUtils.isInOrAboveLiquid
16
14
import com.lambda.client.util.MovementUtils
17
15
import com.lambda.client.util.MovementUtils.applySpeedPotionEffects
18
16
import com.lambda.client.util.MovementUtils.calcMoveYaw
19
- import com.lambda.client.util.MovementUtils.setSpeed
20
- import com.lambda.client.util.MovementUtils.speed
21
- import com.lambda.client.util.TickTimer
22
- import com.lambda.client.util.TimeUnit
23
17
import com.lambda.client.util.threads.runSafe
24
18
import com.lambda.client.util.threads.safeListener
25
- import net.minecraft.client.settings.KeyBinding
26
19
import net.minecraft.network.play.client.CPacketPlayer
27
20
import net.minecraft.network.play.server.SPacketPlayerPosLook
28
21
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -43,12 +36,9 @@ object Speed : Module(
43
36
val mode = setting(" Mode" , SpeedMode .STRAFE )
44
37
45
38
// Strafe settings
46
- private val strafeAirSpeedBoost by setting(" Air Speed Boost" , 0.028f , 0.01f .. 0.04f , 0.001f , { mode.value == SpeedMode .STRAFE })
47
- private val strafeTimerBoost by setting(" Timer Boost" , true , { mode.value == SpeedMode .STRAFE })
48
- private val strafeAutoJump by setting(" Auto Jump" , true , { mode.value == SpeedMode .STRAFE }, description = " WARNING: Food intensive!" )
49
- private val strafeOnlyOverhead by setting(" Only strafe on overhead" , false , { mode.value == SpeedMode .STRAFE && strafeAutoJump })
39
+ private val strafeAirSpeedBoost by setting(" Strafe Speed" , StrafeMode .Normal )
40
+ private val strafeOnlyOverhead by setting(" Require Roof" , false , { mode.value == SpeedMode .STRAFE })
50
41
private val strafeOnHoldingSprint by setting(" On Holding Sprint" , false , { mode.value == SpeedMode .STRAFE })
51
- private val strafeCancelInertia by setting(" Cancel Inertia" , false , { mode.value == SpeedMode .STRAFE })
52
42
53
43
// YPort settings
54
44
private val yPortAccelerate by setting(" Accelerate" , true , { mode.value == SpeedMode .YPORT })
@@ -58,17 +48,17 @@ object Speed : Module(
58
48
private val yPortAcceleration by setting(" Acceleration Speed" , 2.149 , 1.0 .. 5.0 , 0.001 , { mode.value == SpeedMode .YPORT })
59
49
private val yPortDecay by setting(" Decay Amount" , 0.66 , 0.0 .. 1.0 , 0.001 , { mode.value == SpeedMode .YPORT })
60
50
61
- private const val TIMER_SPEED = 45.955883f
62
-
63
- // Strafe Mode
64
- private var jumpTicks = 0
65
- private val strafeTimer = TickTimer (TimeUnit .TICKS )
51
+ private const val TIMER_SPEED = 45.922115f
66
52
67
53
// yport stuff
68
54
private var currentSpeed = .2873
69
55
private var currentY = 0.0
70
- private var phase: YPortPhase = YPortPhase .WALKING
71
- private var prevPhase: YPortPhase = YPortPhase .WALKING
56
+
57
+ private var strafePhase = StrafePhase .ACCELERATING
58
+
59
+ private var yPortPhase = YPortPhase .WALKING
60
+ private var prevYPortPhase = YPortPhase .WALKING
61
+
72
62
private var goUp = false
73
63
private var lastDistance = 0.0
74
64
@@ -85,16 +75,30 @@ object Speed : Module(
85
75
FALLING
86
76
}
87
77
78
+ private enum class StrafePhase {
79
+ // to jump and accelerate
80
+ ACCELERATING ,
81
+ // to fall to the ground
82
+ SLOWDOWN ,
83
+ // to slowly fall to the ground
84
+ FALLING
85
+ }
86
+
88
87
enum class SpeedMode (override val displayName : String ) : DisplayEnum {
89
88
STRAFE (" Strafe" ),
90
89
YPORT (" YPort" )
91
90
}
92
91
92
+ enum class StrafeMode {
93
+ Normal , Strict
94
+ }
95
+
93
96
init {
94
97
onEnable {
95
98
currentSpeed = .2873
96
- phase = YPortPhase .WALKING
97
- prevPhase = YPortPhase .WALKING
99
+ strafePhase = StrafePhase .ACCELERATING
100
+ yPortPhase = YPortPhase .WALKING
101
+ prevYPortPhase = YPortPhase .WALKING
98
102
goUp = false
99
103
currentY = 0.0
100
104
}
@@ -107,23 +111,12 @@ object Speed : Module(
107
111
108
112
safeListener<TickEvent .ClientTickEvent > {
109
113
lastDistance = hypot(player.posX - player.prevPosX, player.posZ - player.prevPosZ)
110
- if (mode.value == SpeedMode .STRAFE
111
- && shouldStrafe()
112
- ) strafe()
113
114
}
114
115
115
116
safeListener<PlayerMoveEvent > {
116
117
when (mode.value) {
117
118
SpeedMode .STRAFE -> {
118
- if (shouldStrafe()) {
119
- setSpeed(max(player.speed, applySpeedPotionEffects(0.2873 )))
120
- } else {
121
- reset()
122
- if (strafeCancelInertia && ! strafeTimer.tick(2L , false )) {
123
- player.motionX = 0.0
124
- player.motionZ = 0.0
125
- }
126
- }
119
+ handleStrafe(it)
127
120
}
128
121
129
122
SpeedMode .YPORT -> {
@@ -152,14 +145,14 @@ object Speed : Module(
152
145
153
146
if (currentY + unModOffset > 0 )
154
147
offset + = currentY
155
- else if (yPortAirStrict && phase == YPortPhase .FALLING && prevPhase == YPortPhase .FALLING ) {
148
+ else if (yPortAirStrict && yPortPhase == YPortPhase .FALLING && prevYPortPhase == YPortPhase .FALLING ) {
156
149
157
150
var predictedY = currentY
158
151
predictedY - = 0.08
159
152
predictedY * = 0.9800000190734863 // 0.333200006 vs 0.341599999
160
153
161
154
if (predictedY + player.posY <= player.posY) {
162
- phase = YPortPhase .WAITING
155
+ yPortPhase = YPortPhase .WAITING
163
156
}
164
157
}
165
158
@@ -175,55 +168,23 @@ object Speed : Module(
175
168
currentY = 0.0
176
169
goUp = false
177
170
// 3 extra ticks at base speed
178
- phase = YPortPhase .WAITING
171
+ yPortPhase = YPortPhase .WAITING
179
172
}
180
173
181
174
mode.listeners.add {
182
175
runSafe { reset() }
183
176
}
184
177
}
185
178
186
- private fun SafeClientEvent.strafe () {
187
- player.jumpMovementFactor = strafeAirSpeedBoost
188
- // slightly slower timer speed bypasses better (1.088)
189
- if (strafeTimerBoost) modifyTimer(TIMER_SPEED )
190
-
191
- if ((Step .isDisabled || player.onGround) && strafeAutoJump) jump()
192
-
193
- strafeTimer.reset()
194
- }
195
-
196
179
private fun SafeClientEvent.shouldStrafe (): Boolean =
197
180
! player.capabilities.isFlying
198
181
&& ! player.isElytraFlying
199
- && ! mc.gameSettings.keyBindSneak.isKeyDown
200
- && (! strafeOnHoldingSprint || mc.gameSettings.keyBindSprint.isKeyDown)
201
182
&& ! BaritoneUtils .isPathing
202
183
&& MovementUtils .isInputting
203
- && ! (player.isInOrAboveLiquid || player.isInWeb)
204
- && (! strafeOnlyOverhead || world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0 ,.42 ,.0 )))
205
184
206
185
private fun SafeClientEvent.reset () {
207
186
player.jumpMovementFactor = 0.02f
208
187
resetTimer()
209
- jumpTicks = 0
210
- }
211
-
212
- private fun SafeClientEvent.jump () {
213
- if (player.onGround && jumpTicks <= 0 ) {
214
- if (player.isSprinting) {
215
- val yaw = calcMoveYaw()
216
- player.motionX - = sin(yaw) * 0.2
217
- player.motionZ + = cos(yaw) * 0.2
218
- }
219
-
220
- KeyBinding .setKeyBindState(mc.gameSettings.keyBindJump.keyCode, false )
221
- player.motionY = 0.4
222
- player.isAirBorne = true
223
- jumpTicks = 5
224
- }
225
-
226
- jumpTicks--
227
188
}
228
189
229
190
private fun SafeClientEvent.handleBoost (event : PlayerMoveEvent ) {
@@ -240,13 +201,13 @@ object Speed : Module(
240
201
241
202
modifyTimer(TIMER_SPEED )
242
203
243
- prevPhase = phase
204
+ prevYPortPhase = yPortPhase
244
205
245
- when (phase ) {
206
+ when (yPortPhase ) {
246
207
YPortPhase .ACCELERATING -> {
247
208
// NCP says hDistance < 2.15 * hDistanceBaseRef
248
209
currentSpeed * = yPortAcceleration
249
- phase = if (yPortAirStrict) YPortPhase .FALLING else YPortPhase .SLOWDOWN
210
+ yPortPhase = if (yPortAirStrict) YPortPhase .FALLING else YPortPhase .SLOWDOWN
250
211
goUp = true
251
212
currentY = 0.0
252
213
}
@@ -258,12 +219,12 @@ object Speed : Module(
258
219
} else {
259
220
.2873
260
221
}
261
- phase = YPortPhase .ACCELERATING
222
+ yPortPhase = YPortPhase .ACCELERATING
262
223
goUp = false
263
224
}
264
225
265
226
YPortPhase .FALLING -> {
266
- if (prevPhase == YPortPhase .WALKING ) {
227
+ if (prevYPortPhase == YPortPhase .WALKING ) {
267
228
currentSpeed = if (yPortAccelerate) {
268
229
lastDistance - yPortDecay * (lastDistance - .2873 )
269
230
} else {
@@ -281,7 +242,7 @@ object Speed : Module(
281
242
282
243
else -> {
283
244
currentSpeed = max(currentSpeed, .2873 )
284
- phase = YPortPhase .values()[phase .ordinal + 1 % YPortPhase .values().size]
245
+ yPortPhase = YPortPhase .values()[yPortPhase .ordinal + 1 % YPortPhase .values().size]
285
246
goUp = false
286
247
}
287
248
}
@@ -298,4 +259,49 @@ object Speed : Module(
298
259
299
260
player.setVelocity(event.x, event.y, event.z)
300
261
}
262
+
263
+ private fun SafeClientEvent.handleStrafe (event : PlayerMoveEvent ) {
264
+ if (! shouldStrafe()) {
265
+ resetTimer()
266
+ event.x = .0
267
+ event.z = .0
268
+ currentSpeed = .2873
269
+ return
270
+ }
271
+
272
+ if (strafeOnlyOverhead && ! world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0 ,.42 ,.0 ))
273
+ || strafeOnHoldingSprint && ! mc.gameSettings.keyBindSprint.isKeyDown)
274
+ return
275
+
276
+ modifyTimer(TIMER_SPEED )
277
+
278
+ val base = applySpeedPotionEffects(.2873 )
279
+
280
+ if (player.onGround)
281
+ strafePhase = StrafePhase .ACCELERATING
282
+
283
+ when (strafePhase) {
284
+ StrafePhase .ACCELERATING -> {
285
+ if (player.onGround)
286
+ event.y = .42
287
+ currentSpeed = base
288
+ currentSpeed * = if (strafeAirSpeedBoost == StrafeMode .Strict ) 1.87 else 1.93
289
+ strafePhase = StrafePhase .SLOWDOWN
290
+ }
291
+
292
+ StrafePhase .SLOWDOWN -> {
293
+ currentSpeed - = .66 * base
294
+ strafePhase = StrafePhase .FALLING
295
+ }
296
+
297
+ StrafePhase .FALLING -> {
298
+ currentSpeed = lastDistance - lastDistance / 159
299
+ }
300
+ }
301
+
302
+ val yaw = calcMoveYaw()
303
+ currentSpeed = currentSpeed.coerceAtLeast(.2873 )
304
+ event.x = - sin(yaw) * currentSpeed
305
+ event.z = cos(yaw) * currentSpeed
306
+ }
301
307
}
0 commit comments