# Velocity ``` /* * LiquidBounce Hacked Client * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge. * https://github.com/CCBlueX/LiquidBounce/ */ package net.ccbluex.liquidbounce.features.module.modules.combat import net.ccbluex.liquidbounce.LiquidBounce import net.ccbluex.liquidbounce.event.EventTarget import net.ccbluex.liquidbounce.event.JumpEvent import net.ccbluex.liquidbounce.event.PacketEvent import net.ccbluex.liquidbounce.event.UpdateEvent import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo import net.ccbluex.liquidbounce.features.module.modules.movement.Speed import net.ccbluex.liquidbounce.utils.MovementUtils import net.ccbluex.liquidbounce.utils.timer.MSTimer import net.ccbluex.liquidbounce.value.BoolValue import net.ccbluex.liquidbounce.value.FloatValue import net.ccbluex.liquidbounce.value.ListValue import net.minecraft.network.play.server.S12PacketEntityVelocity import net.minecraft.network.play.server.S27PacketExplosion import net.minecraft.util.MathHelper @ModuleInfo(name = "Velocity", description = "Allows you to modify the amount of knockback you take.", category = ModuleCategory.COMBAT) class Velocity : Module() { /** * OPTIONS */ private val horizontalValue = FloatValue("Horizontal", 0F, 0F, 1F) private val verticalValue = FloatValue("Vertical", 0F, 0F, 1F) private val modeValue = ListValue("Mode", arrayOf("Simple", "Test", "Test2", "Test3", "Test4", "AAC", "AAC4.4.0", "OAAC", "AACPush", "AACZero", "AAC4.1.0", "Reverse", "SmoothReverse", "SmoothAAC", "HighJump", "HighJump2", "HighJump3", "HighJump4", "Jump", "Glitch", "Glitch2", "LowJump", "LowJump2", "LowJump3", "LowJump4", "LowJump5"), "Simple") // Reverse private val reverseStrengthValue = FloatValue("ReverseStrength", 1F, 0.1F, 1F) private val reverse2StrengthValue = FloatValue("SmoothReverseStrength", 0.05F, 0.02F, 0.1F) // AAC Push private val aacPushXZReducerValue = FloatValue("AACPushXZReducer", 2F, 1F, 3F) private val aacPushYReducerValue = BoolValue("AACPushYReducer", true) private val mode2Value = ListValue("Mode2", arrayOf("Disabled", "Simple", "Test", "Test2", "Test3", "Test4", "AAC", "AAC4.4.0", "OAAC", "AACPush", "AACZero", "AAC4.1.0", "Reverse", "SmoothReverse", "SmoothAAC", "HighJump", "HighJump2", "HighJump3", "HighJump4", "Jump", "Glitch", "Glitch2", "LowJump", "LowJump2", "LowJump3", "LowJump4", "LowJump5"), "Simple") private val horizontalValue2 = FloatValue("Horizontal2", 0F, 0F, 1F) private val verticalValue2 = FloatValue("Vertical2", 0F, 0F, 1F) // Reverse private val reverseStrengthValue2 = FloatValue("ReverseStrength2", 1F, 0.1F, 1F) private val reverse2StrengthValue2 = FloatValue("SmoothReverseStrength2", 0.05F, 0.02F, 0.1F) // AAC Push private val aacPushXZReducerValue2 = FloatValue("AACPushXZReducer2", 2F, 1F, 3F) private val aacPushYReducerValue2 = BoolValue("AACPushYReducer2", true) /** * VALUES */ private var velocityTimer = MSTimer() private var velocityInput = false // SmoothReverse private var reverseHurt = false // AACPush private var jump = false override val tag: String get() = modeValue.get() override fun onDisable() { mc.thePlayer?.speedInAir = 0.02F } @EventTarget fun onUpdate(event: UpdateEvent) { if (mc.thePlayer.isInWater || mc.thePlayer.isInLava || mc.thePlayer.isInWeb) return when (modeValue.get().toLowerCase()) {~ "highjump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 1 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump2" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.90 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump3" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.75 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump4" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.65 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "jump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.42 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.35 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump2" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.30 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump3" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.25 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump4" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.21 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump5" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.15 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "glitch" -> { mc.thePlayer.noClip = velocityInput if (mc.thePlayer.hurtTime == 7) mc.thePlayer.motionY = 0.4 velocityInput = false } "glitch2" -> { mc.thePlayer.noClip = velocityInput if (mc.thePlayer.hurtTime == 7) mc.thePlayer.motionY = 1.0 velocityInput = false } "aac4.4.0" -> { if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.motionX *= 0.6 mc.thePlayer.motionZ *= 0.6 } } "Test" -> { if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.motionX *= -1.05 mc.thePlayer.motionY *= -1.50 mc.thePlayer.motionZ *= -1.05 } } "Test2" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 1.0 mc.thePlayer.motionY *= 1.5 mc.thePlayer.motionZ *= 1.0 mc.thePlayer.speedInAir = 0.0301F } } "Test3" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = false mc.thePlayer.motionX *= 0.5 mc.thePlayer.motionY *= -0.5 mc.thePlayer.motionZ *= 1.3 mc.thePlayer.speedInAir = 0.0301F } } "Test4" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 1.3 mc.thePlayer.motionY *= -1.67 mc.thePlayer.motionZ *= 0.5 mc.thePlayer.speedInAir = 0.0701F } } "oaac" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 0.6 mc.thePlayer.motionZ *= 0.6 mc.thePlayer.speedInAir = 0.0201F } } "reverse" -> { if (!velocityInput) return if (!mc.thePlayer.onGround) { MovementUtils.strafe(MovementUtils.getSpeed() * reverseStrengthValue.get()) } else if (velocityTimer.hasTimePassed(80L)) velocityInput = false } "smoothreverse" -> { if (!velocityInput) { mc.thePlayer.speedInAir = 0.02F return } if (mc.thePlayer.hurtTime > 0) reverseHurt = true if (!mc.thePlayer.onGround) { if (reverseHurt) mc.thePlayer.speedInAir = reverse2StrengthValue.get() } else if (velocityTimer.hasTimePassed(80L)) { velocityInput = false reverseHurt = false } } "smoothaac" -> { if (mc.thePlayer.hurtTime > 0) { mc.thePlayer.speedInAir = 0.04F } } "aac" -> if (velocityInput && velocityTimer.hasTimePassed(80L)) { mc.thePlayer.motionX *= horizontalValue.get() mc.thePlayer.motionZ *= horizontalValue.get() mc.thePlayer.motionY *= verticalValue.get() velocityInput = false } "aacpush" -> { if (jump) { if (mc.thePlayer.onGround) jump = false } else { // Strafe if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.motionX != 0.0 && mc.thePlayer.motionZ != 0.0) mc.thePlayer.onGround = true // Reduce Y if (mc.thePlayer.hurtResistantTime > 0 && aacPushYReducerValue.get() && !LiquidBounce.moduleManager[Speed::class.java]!!.state) mc.thePlayer.motionY -= 0.014999993 } // Reduce XZ if (mc.thePlayer.hurtResistantTime >= 19) { val reduce = aacPushXZReducerValue.get() mc.thePlayer.motionX /= reduce mc.thePlayer.motionZ /= reduce } } "aac4.1.0" -> if (mc.thePlayer.hurtTime > 0) { mc.thePlayer.onGround = true velocityInput = false } "aaczero" -> if (mc.thePlayer.hurtTime > 0) { if (!velocityInput || mc.thePlayer.onGround || mc.thePlayer.fallDistance > 2F) return mc.thePlayer.addVelocity(0.0, -1.0, 0.0) mc.thePlayer.onGround = true } else velocityInput = false } if (mc.thePlayer.isInWater || mc.thePlayer.isInLava || mc.thePlayer.isInWeb) return when (mode2Value.get().toLowerCase()) { "disabled" -> { } "aac4.4.0" -> { if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.motionX *= 0.6 mc.thePlayer.motionZ *= 0.6 } } "Test" -> { if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.motionX *= -1.05 mc.thePlayer.motionY *= -1.50 mc.thePlayer.motionZ *= -1.05 } } "Test2" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 1.0 mc.thePlayer.motionY *= 1.5 mc.thePlayer.motionZ *= 1.0 mc.thePlayer.speedInAir = 0.0301F } } "Test3" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = false mc.thePlayer.motionX *= 0.5 mc.thePlayer.motionY *= -0.5 mc.thePlayer.motionZ *= 1.3 mc.thePlayer.speedInAir = 0.0301F } } "Test4" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 1.3 mc.thePlayer.motionY *= -1.67 mc.thePlayer.motionZ *= 0.5 mc.thePlayer.speedInAir = 0.0701F } } "oaac" -> { if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.posY < 0) { mc.thePlayer.onGround = true mc.thePlayer.motionX *= 0.6 mc.thePlayer.motionZ *= 0.6 mc.thePlayer.speedInAir = 0.0201F } } "highjump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 1 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump2" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.90 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump3" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.75 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "highjump4" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.65 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "jump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.42 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.35 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump2" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.30 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump3" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.25 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump4" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.21 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "lowjump5" -> if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround) { mc.thePlayer.motionY = 0.15 val yaw = mc.thePlayer.rotationYaw * 0.017453292F mc.thePlayer.motionX -= MathHelper.sin(yaw) * 0.2 mc.thePlayer.motionZ += MathHelper.cos(yaw) * 0.2 } "glitch" -> { mc.thePlayer.noClip = velocityInput if (mc.thePlayer.hurtTime == 7) mc.thePlayer.motionY = 0.4 velocityInput = false } "glitch2" -> { mc.thePlayer.noClip = velocityInput if (mc.thePlayer.hurtTime == 7) mc.thePlayer.motionY = 1.0 velocityInput = false } "reverse" -> { if (!velocityInput) return if (!mc.thePlayer.onGround) { MovementUtils.strafe(MovementUtils.getSpeed() * reverseStrengthValue2.get()) } else if (velocityTimer.hasTimePassed(80L)) velocityInput = false } "smoothreverse" -> { if (!velocityInput) { mc.thePlayer.speedInAir = 0.02F return } if (mc.thePlayer.hurtTime > 0) reverseHurt = true if (!mc.thePlayer.onGround) { if (reverseHurt) mc.thePlayer.speedInAir = reverse2StrengthValue2.get() } else if (velocityTimer.hasTimePassed(80L)) { velocityInput = false reverseHurt = false } } "smoothaac" -> { if (mc.thePlayer.hurtTime > 0) { mc.thePlayer.speedInAir = 0.04F } } "aac" -> if (velocityInput && velocityTimer.hasTimePassed(80L)) { mc.thePlayer.motionX *= horizontalValue2.get() mc.thePlayer.motionZ *= horizontalValue2.get() mc.thePlayer.motionY *= verticalValue2.get() velocityInput = false } "aacpush" -> { if (jump) { if (mc.thePlayer.onGround) jump = false } else { // Strafe if (mc.thePlayer.hurtTime > 0 && mc.thePlayer.motionX != 0.0 && mc.thePlayer.motionZ != 0.0) mc.thePlayer.onGround = true // Reduce Y if (mc.thePlayer.hurtResistantTime > 0 && aacPushYReducerValue2.get() && !LiquidBounce.moduleManager[Speed::class.java]!!.state) mc.thePlayer.motionY -= 0.014999993 } // Reduce XZ if (mc.thePlayer.hurtResistantTime >= 19) { val reduce = aacPushXZReducerValue2.get() mc.thePlayer.motionX /= reduce mc.thePlayer.motionZ /= reduce } } "aac4.1.0" -> if (mc.thePlayer.hurtTime > 0) { mc.thePlayer.onGround = true velocityInput = false } "aaczero" -> if (mc.thePlayer.hurtTime > 0) { if (!velocityInput || mc.thePlayer.onGround || mc.thePlayer.fallDistance > 2F) return mc.thePlayer.addVelocity(0.0, -1.0, 0.0) mc.thePlayer.onGround = true } else velocityInput = false } } @EventTarget fun onPacket(event: PacketEvent) { val packet = event.packet if (packet is S12PacketEntityVelocity) { if (mc.thePlayer == null || (mc.theWorld?.getEntityByID(packet.entityID) ?: return) != mc.thePlayer) return velocityTimer.reset() when (modeValue.get().toLowerCase()) { "simple" -> { val horizontal = horizontalValue.get() val vertical = verticalValue.get() if (horizontal == 0F && vertical == 0F) event.cancelEvent() packet.motionX = (packet.getMotionX() * horizontal).toInt() packet.motionY = (packet.getMotionY() * vertical).toInt() packet.motionZ = (packet.getMotionZ() * horizontal).toInt() } "aac", "reverse", "smoothreverse", "aaczero", "aac4.4.0" -> velocityInput = true "glitch" -> { if (!mc.thePlayer.onGround) return velocityInput = true event.cancelEvent() } } } if (packet is S12PacketEntityVelocity) { if (mc.thePlayer == null || (mc.theWorld?.getEntityByID(packet.entityID) ?: return) != mc.thePlayer) return velocityTimer.reset() when (mode2Value.get().toLowerCase()) { "simple" -> { val horizontal = horizontalValue.get() val vertical = verticalValue.get() if (horizontal == 0F && vertical == 0F) event.cancelEvent() packet.motionX = (packet.getMotionX() * horizontal).toInt() packet.motionY = (packet.getMotionY() * vertical).toInt() packet.motionZ = (packet.getMotionZ() * horizontal).toInt() } "aac", "reverse", "smoothreverse", "aaczero", "aac4.4.0" -> velocityInput = true "glitch" -> { if (!mc.thePlayer.onGround) return velocityInput = true event.cancelEvent() } } } if (packet is S27PacketExplosion) { // TODO: Support velocity for explosions event.cancelEvent() } } @EventTarget fun onJump(event: JumpEvent) { if (mc.thePlayer == null || mc.thePlayer.isInWater || mc.thePlayer.isInLava || mc.thePlayer.isInWeb) return when (modeValue.get().toLowerCase()) { "aacpush" -> { jump = true if (!mc.thePlayer.isCollidedVertically) event.cancelEvent() } "aaczero" -> if (mc.thePlayer.hurtTime > 0) event.cancelEvent() } when (mode2Value.get().toLowerCase()) { "aacpush" -> { jump = true if (!mc.thePlayer.isCollidedVertically) event.cancelEvent() } "aaczero" -> if (mc.thePlayer.hurtTime > 0) event.cancelEvent() } } } ```