Skip to content

Commit d423693

Browse files
Add AntiLevitation.kt fly mode (#259)
* Add AntiLevitation.kt fly mode * replace the stupid capability fly * Make the motion more smooth and fix speed * Cleanup + add timer boost * Add a legit mode * Make the Y motion lower so it actually works with levitation 1 lol * Improve the values a bit * Add else return statement to make SolarLint happy * Cleanup * Cleanup Co-authored-by: Constructor <[email protected]>
1 parent e15436b commit d423693

File tree

1 file changed

+89
-2
lines changed

1 file changed

+89
-2
lines changed

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

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,107 @@
11
package com.lambda.client.module.modules.movement
22

3+
import com.lambda.client.event.events.PlayerTravelEvent
4+
import com.lambda.client.manager.managers.TimerManager.modifyTimer
5+
import com.lambda.client.manager.managers.TimerManager.resetTimer
36
import com.lambda.client.module.Category
47
import com.lambda.client.module.Module
8+
import com.lambda.client.util.MovementUtils
9+
import com.lambda.client.util.MovementUtils.calcMoveYaw
10+
import com.lambda.client.util.MovementUtils.isMoving
11+
import com.lambda.client.util.MovementUtils.setSpeed
12+
import com.lambda.client.util.text.MessageSendHelper
513
import com.lambda.client.util.threads.safeListener
614
import net.minecraft.init.MobEffects
715
import net.minecraftforge.fml.common.gameevent.TickEvent
16+
import kotlin.math.cos
17+
import kotlin.math.sin
818

919
object AntiLevitation : Module(
1020
name = "AntiLevitation",
11-
description = "Removes levitation potion effect",
21+
description = "Removes levitation effect (boring) or abuse it (epic)",
1222
category = Category.MOVEMENT
1323
) {
24+
private val mode by setting("Mode", Mode.LEGIT, description = "The AntiLevitation mode")
25+
26+
/* Flight mode */
27+
private val vertical by setting("Only Vertical", false, { mode == Mode.FLIGHT }, description = "doesn't apply extra speed when enabled")
28+
private val yMotion by setting("Y Motion", 0.002f, 0.0f..0.02f, 0.001f, { mode == Mode.FLIGHT }, description = "The Y Motion that is applied when moving to bypass the anticheat")
29+
private val speed by setting("Speed", 0.28f, 0.15f..0.3f, 0.005f, { !vertical && mode == Mode.FLIGHT }, description = "The speed you fly at")
30+
private val timer by setting("Timer Boost", true, { !vertical && mode == Mode.FLIGHT }, description = "Use timer for a slight speed boost")
31+
private val timerSpeed by setting("Timer Speed", 1.15f, 1.1f..1.2f, 0.01f, { timer && !vertical && mode == Mode.FLIGHT }, description = "The timer modifier")
32+
33+
/* Legit mode */
34+
private val legitYMotion by setting("Motion Up", 0.018f, 0.001f..0.1f, 0.001f, { mode == Mode.LEGIT }, description = "The Y Motion that is applied when moving to bypass the anticheat")
35+
private val boost by setting("Sprint Boost", true, { mode == Mode.LEGIT }, description = "Gives you extra motion when control is pressed")
36+
37+
/* Jump motion (used by flight mode and legit mode) */
38+
private val jumpMotion by setting("Jump Motion", 0.099f, 0.090f..0.10f, 0.001f, { mode == Mode.FLIGHT || mode == Mode.LEGIT }, description = "The Y Motion that is applied when you press space")
39+
40+
private var ready = false
41+
42+
private enum class Mode {
43+
REMOVE, FLIGHT, LEGIT
44+
}
45+
1446
init {
47+
onDisable {
48+
ready = false
49+
resetTimer()
50+
}
51+
1552
safeListener<TickEvent.ClientTickEvent> {
1653
if (player.isPotionActive(MobEffects.LEVITATION)) {
17-
player.removeActivePotionEffect(MobEffects.LEVITATION)
54+
if (mode != Mode.REMOVE && !ready) {
55+
ready = true
56+
MessageSendHelper.sendChatMessage("You can now fly.")
57+
}
58+
if (mode == Mode.REMOVE) {
59+
player.removeActivePotionEffect(MobEffects.LEVITATION)
60+
MessageSendHelper.sendChatMessage("Removed levitation effect.")
61+
}
62+
} else {
63+
if (ready) {
64+
resetTimer()
65+
MessageSendHelper.sendWarningMessage("Levitation ran out. Brace for impact....")
66+
player.setVelocity(0.0, 0.0, 0.0)
67+
ready = false
68+
}
69+
}
70+
}
71+
72+
safeListener<PlayerTravelEvent> {
73+
if (!ready) return@safeListener
74+
75+
if (mode == Mode.FLIGHT) {
76+
if (MovementUtils.isInputting && !vertical) {
77+
player.isSprinting = false //disables sprinting so you can't go too fast
78+
setSpeed(speed.toDouble())
79+
if (timer && !vertical) modifyTimer(50.0f / timerSpeed)
80+
} else {
81+
player.motionY = 0.0
82+
/* Make the motion slowly become 0, so it flattens out smooth */
83+
player.motionX *= 0.8
84+
player.motionZ *= 0.8
85+
}
86+
87+
if (MovementUtils.isInputting || player.isMoving) {
88+
player.motionY = yMotion.toDouble()
89+
}
90+
91+
if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY = jumpMotion.toDouble()
92+
if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = -0.49
93+
} else if (mode == Mode.LEGIT) {
94+
/* Override vanilla motion with our own motion */
95+
player.motionY = legitYMotion.toDouble()
96+
97+
if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY = jumpMotion.toDouble()
98+
if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = 0.005
99+
100+
if (mc.gameSettings.keyBindSprint.isKeyDown && player.isSprinting && boost) { //player must be sprinting so you can only boost when you press W
101+
val yaw = calcMoveYaw()
102+
player.motionX = -sin(yaw) * 0.26
103+
player.motionZ = cos(yaw) * 0.26
104+
}
18105
}
19106
}
20107
}

0 commit comments

Comments
 (0)