|
1 | 1 | package com.lambda.client.module.modules.movement
|
2 | 2 |
|
| 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 |
3 | 6 | import com.lambda.client.module.Category
|
4 | 7 | 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 |
5 | 13 | import com.lambda.client.util.threads.safeListener
|
6 | 14 | import net.minecraft.init.MobEffects
|
7 | 15 | import net.minecraftforge.fml.common.gameevent.TickEvent
|
| 16 | +import kotlin.math.cos |
| 17 | +import kotlin.math.sin |
8 | 18 |
|
9 | 19 | object AntiLevitation : Module(
|
10 | 20 | name = "AntiLevitation",
|
11 |
| - description = "Removes levitation potion effect", |
| 21 | + description = "Removes levitation effect (boring) or abuse it (epic)", |
12 | 22 | category = Category.MOVEMENT
|
13 | 23 | ) {
|
| 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 | + |
14 | 46 | init {
|
| 47 | + onDisable { |
| 48 | + ready = false |
| 49 | + resetTimer() |
| 50 | + } |
| 51 | + |
15 | 52 | safeListener<TickEvent.ClientTickEvent> {
|
16 | 53 | 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 | + } |
18 | 105 | }
|
19 | 106 | }
|
20 | 107 | }
|
|
0 commit comments