From c10a65d5a8f58e26303632e414db499a2289c8e8 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 10 Jul 2024 16:52:54 -0600 Subject: [PATCH] OverrideDirection --- .../module/modules/combat/Velocity.kt | 17 +++-- .../combat/velocitymodes/vanilla/Custom.kt | 64 +++++++++++++++---- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt index 3ba86c31..d2310459 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt @@ -34,12 +34,15 @@ object Velocity : Module("Velocity", COMBAT) { private val onlyGround by BooleanValue("OnlyGround", false) { mode !in arrayOf("AACv4", "AACPush") } private val explosions by BooleanValue("Explosions", true) { mode !in arrayOf("AACv4", "AACPush", "Matrix") } - val multiplyAddedMotion by BooleanValue("MultiplyAddedMotion", true) { mode == "Custom" } - val cancelHorizontal by BooleanValue("CancelHorizontal", true) { mode == "Custom" && !multiplyAddedMotion } - val cancelVertical by BooleanValue("CancelVertical", true) { mode == "Custom" && !multiplyAddedMotion } - val horizontalMultiplier by FloatValue("HorizontalMultiplier", 0f, 0f..1f) { mode == "Custom" && (!cancelHorizontal || multiplyAddedMotion) } - val verticalMultiplier by FloatValue("VerticalMultiplier", 0f, 0f..1f) { mode == "Custom" && (!cancelVertical || multiplyAddedMotion) } - val chance by FloatValue("Chance", 100f, 0f..100f) { mode == "Custom" } + val modify by BooleanValue("Modify", false) { mode == "Custom" } + val overrideDirection by BooleanValue("OverrideDirection", true) { mode == "Custom" && modify } + val overrideDirectionRotation by ListValue("OverrideDirectionRotation", arrayOf("Server", "Client"), "Client") { mode == "Custom" && modify } + val modifyAddedMotion by BooleanValue("ModifyAddedMotion", true) { mode == "Custom" && modify } + val cancelHorizontal by BooleanValue("CancelHorizontal", true) { mode == "Custom" && modify && !modifyAddedMotion } + val cancelVertical by BooleanValue("CancelVertical", true) { mode == "Custom" && modify && !modifyAddedMotion } + val horizontalMultiplier by FloatValue("HorizontalMultiplier", 0f, 0f..1f) { mode == "Custom" && modify && (!cancelHorizontal || modifyAddedMotion) } + val verticalMultiplier by FloatValue("VerticalMultiplier", 0f, 0f..1f) { mode == "Custom" && modify && (!cancelVertical || modifyAddedMotion) } + val chance by FloatValue("Chance", 100f, 0f..100f) { mode == "Custom" && modify } val attackReduce by BooleanValue("AttackReduce", false) { mode == "Custom" } val attackReduceMultiplier by FloatValue("AttackReduce-Multiplier", 0.8f, 0f..1f) { mode == "Custom" && attackReduce } val jump by BooleanValue("Jump", false) { mode == "Custom" } @@ -51,7 +54,7 @@ object Velocity : Module("Velocity", COMBAT) { val tickreduceVertical by BooleanValue("TickReduce-Vertical", false) { mode == "Custom" && tickreduce } val tickreduceHorizontal by BooleanValue("TickReduce-Horizontal", false) { mode == "Custom" && tickreduce } val reverse by BooleanValue("Reverse", false) { mode == "Custom" } - val onLook by BooleanValue("onLook", false) { reverse } + val onLook by BooleanValue("onLook", false) { mode == "Custom" && reverse } val range by FloatValue("Range", 3.0F, 1F..5.0F) { onLook && reverse } val maxAngleDifference by DoubleValue("MaxAngleDifference", 45.0, 5.0..90.0) { onLook && reverse } val reverseSmooth by BooleanValue("Reverse-Smooth", false) { mode == "Custom" && reverse } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/velocitymodes/vanilla/Custom.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/velocitymodes/vanilla/Custom.kt index 645d9100..7b372303 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/velocitymodes/vanilla/Custom.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/velocitymodes/vanilla/Custom.kt @@ -16,8 +16,11 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.jump import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.jumpFailRate import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.jumpMotion import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.maxAngleDifference -import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.multiplyAddedMotion +import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.modify +import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.modifyAddedMotion import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.onLook +import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.overrideDirection +import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.overrideDirectionRotation import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.range import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.reverse import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity.reverseNoGround @@ -35,11 +38,15 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.velocitymodes.Vel import net.ccbluex.liquidbounce.utils.* import net.ccbluex.liquidbounce.utils.EntityUtils.isLookingOnEntities import net.ccbluex.liquidbounce.utils.MovementUtils.speed +import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation import net.ccbluex.liquidbounce.utils.extensions.* import net.ccbluex.liquidbounce.utils.misc.RandomUtils.chanceOf import net.minecraft.entity.Entity import net.minecraft.network.play.server.S12PacketEntityVelocity import net.minecraft.network.play.server.S27PacketExplosion +import kotlin.math.cos +import kotlin.math.sin +import kotlin.math.sqrt /** * @author CCBlueX/LiquidBounce @@ -49,24 +56,59 @@ import net.minecraft.network.play.server.S27PacketExplosion */ object Custom : VelocityMode("Custom") { override fun onVelocityPacket(event: PacketEvent) { + if (!modify) return + val packet = event.packet chanceOf(chance / 100.0) { if (packet is S12PacketEntityVelocity) { event.cancelEvent() - if (multiplyAddedMotion) mc.thePlayer.setVelocity( - mc.thePlayer.motionX + (packet.realMotionX - mc.thePlayer.motionX) * horizontalMultiplier, - mc.thePlayer.motionY + (packet.realMotionY - mc.thePlayer.motionY) * verticalMultiplier, - mc.thePlayer.motionZ + (packet.realMotionZ - mc.thePlayer.motionZ) * horizontalMultiplier - ) else mc.thePlayer.setVelocity( - if (cancelHorizontal) mc.thePlayer.motionX else packet.realMotionX * horizontalMultiplier, - if (cancelVertical) mc.thePlayer.motionY else packet.realMotionY * verticalMultiplier, - if (cancelHorizontal) mc.thePlayer.motionZ else packet.realMotionZ * horizontalMultiplier - ) + + var x = packet.realMotionX + var y = packet.realMotionY + var z = packet.realMotionZ + + if (overrideDirection) { + val yaw = when (overrideDirectionRotation) { + "Server" -> currentRotation?.yaw ?: mc.thePlayer.rotationYaw + else -> mc.thePlayer.rotationYaw + }.plus(90).toRadiansD() + + val dist = sqrt(x * x + z * z) + + x = cos(yaw) * dist + z = sin(yaw) * dist + } + + if (modifyAddedMotion) { + x -= mc.thePlayer.motionX + y -= mc.thePlayer.motionY + z -= mc.thePlayer.motionZ + } + + x *= horizontalMultiplier + y *= verticalMultiplier + z *= horizontalMultiplier + + if (modifyAddedMotion) { + x += mc.thePlayer.motionX + y += mc.thePlayer.motionY + z += mc.thePlayer.motionZ + } else { + if (cancelVertical) { + y = mc.thePlayer.motionY + } + if (cancelHorizontal) { + x = mc.thePlayer.motionX + z = mc.thePlayer.motionZ + } + } + + mc.thePlayer.setVelocity(x, y, z) } if (packet is S27PacketExplosion) { - if (multiplyAddedMotion) { + if (modifyAddedMotion) { packet.field_149152_f *= horizontalMultiplier packet.field_149153_g *= verticalMultiplier packet.field_149159_h *= horizontalMultiplier