Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
OverrideDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Jul 10, 2024
1 parent ae05d91 commit c10a65d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c10a65d

Please sign in to comment.