1
+ package com.lambda.client.module.modules.movement
2
+
3
+ import com.lambda.client.commons.interfaces.DisplayEnum
4
+ import com.lambda.client.event.events.PacketEvent
5
+ import com.lambda.client.event.events.PlayerMoveEvent
6
+ import com.lambda.client.module.Category
7
+ import com.lambda.client.module.Module
8
+ import com.lambda.client.util.BaritoneUtils
9
+ import com.lambda.client.util.MovementUtils.applySpeedPotionEffects
10
+ import com.lambda.client.util.MovementUtils.calcMoveYaw
11
+ import com.lambda.client.util.MovementUtils.isInputting
12
+ import com.lambda.client.util.threads.safeListener
13
+ import net.minecraft.network.play.server.SPacketPlayerPosLook
14
+ import net.minecraftforge.fml.common.gameevent.TickEvent
15
+ import kotlin.math.cos
16
+ import kotlin.math.hypot
17
+ import kotlin.math.sin
18
+
19
+
20
+ /* *
21
+ * @author Doogie13
22
+ * @since 17/03/2023
23
+ */
24
+ object LongJump : Module(
25
+ name = " LongJump" ,
26
+ description = " Allows you to abuse velocity to jump further" ,
27
+ category = Category .MOVEMENT
28
+ ) {
29
+
30
+ private val mode by setting(" Mode" , Mode .STANDARD , description = " How to boost your motion" )
31
+ private var speed by setting(" Speed" , 3.8 , 0.0 .. 10.0 , 0.001 , description = " How much to boost your initial motion" )
32
+
33
+ private val virtue by setting(" Glide" , false , description = " Glide along the ground after jumping" ) // reasonably major 2014 exploit, works on UpdatedNCP in 2023
34
+
35
+ enum class Mode (override val displayName : String ) : DisplayEnum {
36
+ STANDARD (" Standard" ),
37
+ UPDATED (" UpdatedNCP" )
38
+ }
39
+
40
+ private var currentSpeed = .2873
41
+ private var strafePhase = StandardPhase .HEAD_START
42
+ private var lastDistance = 0.0
43
+ private var jumpTick = 0
44
+
45
+ init {
46
+
47
+ onEnable {
48
+ strafePhase = StandardPhase .HEAD_START
49
+ currentSpeed = .2873
50
+ lastDistance = 0.0
51
+ jumpTick = 0
52
+ }
53
+
54
+ safeListener<PacketEvent .Receive > {
55
+ if (it.packet is SPacketPlayerPosLook ) {
56
+ currentSpeed = .0
57
+ disable()
58
+ }
59
+ }
60
+
61
+ safeListener<TickEvent .ClientTickEvent > {
62
+
63
+ if (it.phase != TickEvent .Phase .START )
64
+ return @safeListener
65
+
66
+ lastDistance = hypot(player.posX - player.lastTickPosX, player.posZ - player.lastTickPosZ)
67
+
68
+ }
69
+
70
+ safeListener<PlayerMoveEvent > {
71
+
72
+ val base = applySpeedPotionEffects(.2873 )
73
+ val adjSpeed = speed * base // this seems to be what future uses so its what people are expecting
74
+ val yaw = calcMoveYaw()
75
+
76
+ if (player.capabilities.isFlying
77
+ || player.isElytraFlying
78
+ || BaritoneUtils .isPathing
79
+ || ! isInputting) {
80
+ strafePhase = StandardPhase .HEAD_START
81
+ return @safeListener
82
+ }
83
+
84
+ when (mode) {
85
+
86
+ Mode .STANDARD -> {
87
+
88
+ when (strafePhase) {
89
+
90
+ StandardPhase .HEAD_START -> {
91
+ if (! player.onGround) {
92
+ strafePhase = StandardPhase .SLOWDOWN
93
+ return @safeListener
94
+ }
95
+ currentSpeed = adjSpeed / 2.149
96
+ strafePhase = StandardPhase .ACCELERATING
97
+ }
98
+
99
+ StandardPhase .ACCELERATING -> {
100
+ currentSpeed = adjSpeed
101
+ player.motionY = .424 // slightly higher than normal which is good for LJ
102
+ strafePhase = StandardPhase .SLOWDOWN
103
+ }
104
+
105
+ StandardPhase .SLOWDOWN -> {
106
+ currentSpeed - = .66 * base
107
+ strafePhase = StandardPhase .FALLING
108
+ }
109
+
110
+ StandardPhase .FALLING -> {
111
+
112
+ if (player.onGround) {
113
+ strafePhase = StandardPhase .ACCELERATING
114
+ return @safeListener
115
+ }
116
+
117
+ currentSpeed = lastDistance - lastDistance / 159
118
+ }
119
+
120
+ }
121
+
122
+ it.x = - sin(yaw) * currentSpeed
123
+ it.z = cos(yaw) * currentSpeed
124
+
125
+ if (
126
+ virtue
127
+ && isInputting
128
+ && world.collidesWithAnyBlock(player.entityBoundingBox.shrink(0.0625 ).expand(0.0 , - 0.55 , 0.0 ))
129
+ && player.motionY < 0
130
+ && currentSpeed > .29
131
+ && strafePhase == StandardPhase .FALLING
132
+ ) {
133
+ it.y = - 1e- 7
134
+ }
135
+
136
+ }
137
+
138
+ Mode .UPDATED -> {
139
+
140
+ // we cannot spam this on UpdatedNCP
141
+ if (jumpTick > 1 && player.onGround) {
142
+ disable()
143
+ return @safeListener
144
+ }
145
+
146
+ if (player.onGround) {
147
+ player.jump()
148
+ it.x = - sin(yaw) * base
149
+ it.z = cos(yaw) * base
150
+ jumpTick = 1
151
+ return @safeListener
152
+ }
153
+
154
+ if (++ jumpTick == 2 ) {
155
+ it.x = - sin(yaw) * adjSpeed
156
+ it.z = cos(yaw) * adjSpeed
157
+ return @safeListener
158
+ }
159
+
160
+ if (jumpTick < 8 ) {
161
+ val newSpeed = lastDistance - lastDistance / 159
162
+ it.x = - sin(yaw) * newSpeed
163
+ it.z = cos(yaw) * newSpeed
164
+ }
165
+
166
+ if (
167
+ virtue
168
+ && isInputting
169
+ && world.collidesWithAnyBlock(player.entityBoundingBox.shrink(0.0625 ).expand(0.0 , - 0.55 , 0.0 ))
170
+ && player.motionY < 0
171
+ && currentSpeed > .29
172
+ ) {
173
+ it.y = - 1e- 7
174
+ }
175
+
176
+ }
177
+
178
+ }
179
+
180
+ }
181
+
182
+ }
183
+
184
+ private enum class StandardPhase {
185
+ // slide along the ground slower to bypass
186
+ HEAD_START ,
187
+
188
+ // to jump and accelerate
189
+ ACCELERATING ,
190
+
191
+ // to fall to the ground
192
+ SLOWDOWN ,
193
+
194
+ // to slowly fall to the ground
195
+ FALLING
196
+ }
197
+
198
+ }
0 commit comments