@@ -13,6 +13,7 @@ import com.lambda.client.module.Module
1313import com.lambda.client.util.MovementUtils
1414import com.lambda.client.util.MovementUtils.calcMoveYaw
1515import com.lambda.client.util.threads.runSafe
16+ import com.lambda.client.util.threads.runSafeR
1617import com.lambda.client.util.threads.safeListener
1718import net.minecraft.network.play.client.CPacketConfirmTeleport
1819import net.minecraft.network.play.client.CPacketPlayer
@@ -40,7 +41,7 @@ object Flight : Module(
4041 private val packetMode by setting(" Packet Mode" , PacketMode .FAST , { mode == FlightMode .PACKET })
4142 private val bounds by setting(" Packet Type" , PacketType .NEGATIVE , { mode == FlightMode .PACKET })
4243 private val factor by setting(" Bypass Factor" , 1f , 0f .. 10f , .1f , { mode == FlightMode .PACKET })
43- private val concealFactor by setting(" Conceal Factor" , 2f ,0f .. 10f , .1f , { mode == FlightMode .PACKET })
44+ private val concealFactor by setting(" Conceal Factor" , 2f , 0f .. 10f , .1f , { mode == FlightMode .PACKET })
4445 private val conceal by setting(" Conceal" , false , { mode == FlightMode .PACKET })
4546 private val antiKick by setting(" Anti Kick" , true , { mode == FlightMode .PACKET })
4647
@@ -69,7 +70,6 @@ object Flight : Module(
6970 init {
7071 onDisable {
7172 runSafe {
72-
7373 tpID = - 1
7474 ticksEnabled = 0
7575 player.noClip = false
@@ -78,32 +78,27 @@ object Flight : Module(
7878 isFlying = false
7979 flySpeed = 0.05f
8080 }
81-
8281 }
8382 }
8483
8584 onEnable {
86- runSafe {
85+ runSafeR {
8786 val position = CPacketPlayer .Position (.0 , .0 , .0 , true )
8887 filter.add(position)
8988 connection.sendPacket(position)
90- }
89+ } ? : disable()
9190 }
9291
9392 safeListener<PlayerMoveEvent > {
9493 when (mode) {
95-
9694 // uses the same concepts as https://gist.github.com/Doogie13/aa04c6a8eb496c1afdb9c675e2ebd91c
9795 // completely written from scratch, however
9896 FlightMode .PACKET -> {
99-
10097 player.noClip = true
10198
10299 // region Motion
103100 val concealing = world.collidesWithAnyBlock(player.entityBoundingBox) || conceal
104-
105101 var motionY: Double
106-
107102 var up = 0
108103
109104 // we must use else if to allow phasing
@@ -112,11 +107,10 @@ object Flight : Module(
112107 else if (mc.gameSettings.keyBindSneak.isKeyDown)
113108 up--
114109
115- motionY =
116- if (up == 0 )
117- .0
118- else
119- CONCEAL_SPEED * up.toDouble()
110+ motionY = if (up == 0 )
111+ .0
112+ else
113+ CONCEAL_SPEED * up.toDouble()
120114
121115 var motionXZ: Double = if (! MovementUtils .isInputting)
122116 .0
@@ -167,8 +161,7 @@ object Flight : Module(
167161 var currentY = if (antiKick && ticksEnabled % 10 == 0 ) - ANTIKICK_AMOUNT else baseY
168162 var currentZ = baseZ
169163
170- for (i in 1 .. (factorInt)) {
171-
164+ for (i in 1 .. factorInt) {
172165 // should never happen
173166 if (i > 10 )
174167 break
@@ -179,30 +172,20 @@ object Flight : Module(
179172
180173 // region bounds
181174 when (bounds) {
182-
183175 PacketType .STRICT -> {
184-
185176 var random = (Math .random() * 256 ) + 256
186177
187178 (random + player.posY > (if (player.dimension == - 1 ) 127 else 255 ))
188179 random * = - 1
189180
190181 yOffset = random
191-
192182 }
193-
194183 PacketType .POSITIVE -> {
195-
196184 yOffset = 1337.0
197-
198185 }
199-
200186 PacketType .NEGATIVE -> {
201-
202187 yOffset = - 1337.0
203-
204188 }
205-
206189 }
207190 // endregion
208191
@@ -236,16 +219,12 @@ object Flight : Module(
236219 player.setVelocity(.0 , .0 , .0 )
237220
238221 }
239-
240222 FlightMode .STATIC -> {
241-
242223 var up = 0
243224
244- if (mc.gameSettings.keyBindJump.isKeyDown)
245- up++
225+ if (mc.gameSettings.keyBindJump.isKeyDown) up++
246226
247- if (mc.gameSettings.keyBindSneak.isKeyDown)
248- up--
227+ if (mc.gameSettings.keyBindSneak.isKeyDown) up--
249228
250229 player.motionY = if (up == 0 ) - glideSpeed else speed * up.toDouble()
251230
@@ -257,7 +236,6 @@ object Flight : Module(
257236 player.motionZ + = cos(yaw) * speed
258237
259238 }
260-
261239 FlightMode .VANILLA -> {
262240 player.capabilities.isFlying = true
263241 player.capabilities.flySpeed = speed / 11.11f
@@ -266,9 +244,7 @@ object Flight : Module(
266244 && ! mc.gameSettings.keyBindJump.isKeyDown
267245 && ! mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = - glideSpeed
268246 }
269-
270247 }
271-
272248 }
273249
274250 listener<OnUpdateWalkingPlayerEvent > {
@@ -279,57 +255,39 @@ object Flight : Module(
279255 }
280256
281257 safeListener<PacketEvent .Receive > {
258+ if (mode != FlightMode .PACKET ) return @safeListener
282259
283- if (mode != FlightMode .PACKET )
284- return @safeListener
285-
286- when (it.packet) {
287-
260+ when (val packet = it.packet) {
288261 is SPacketPlayerPosLook -> {
289-
290- val packet = it.packet
291262 val id = packet.teleportId
292263
293- if (history.containsKey(id) && tpID != - 1 ) {
294-
295- val vec = history[id]
296-
297- if (vec != null ) {
298-
264+ if (history.containsKey(packet.teleportId) && tpID != - 1 ) {
265+ history[id]?.let { vec ->
299266 if (vec.x == packet.x && vec.y == packet.y && vec.z == packet.z) {
300-
301267 if (packetMode != PacketMode .SETBACK )
302268 it.cancel()
303269
304270 history.remove(id)
305-
306271 player.connection.sendPacket(CPacketConfirmTeleport (id))
307-
308272 return @safeListener
309-
310273 }
311-
312274 }
313275 }
314276
315- it. packet.playerPosLookYaw = player.rotationYaw
316- it. packet.playerPosLookPitch = player.rotationPitch
277+ packet.playerPosLookYaw = player.rotationYaw
278+ packet.playerPosLookPitch = player.rotationPitch
317279
318280 player.connection.sendPacket(CPacketConfirmTeleport (id))
319281
320282 tpID = id
321-
322283 }
323-
324284 is SPacketCloseWindow -> {
325285 it.cancel()
326286 }
327-
328287 }
329288 }
330289
331290 safeListener<PacketEvent .Send > {
332-
333291 if (mode != FlightMode .PACKET || it.packet !is CPacketPlayer ) return @safeListener
334292
335293 if (! filter.contains(it.packet))
@@ -338,6 +296,5 @@ object Flight : Module(
338296 filter.remove(it.packet)
339297
340298 }
341-
342299 }
343300}
0 commit comments