Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(legacy): add MinRotationDiffFromEnemyToIgnore to SuperKnockback #3631

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.MovementUtils.isMoving
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.extensions.stopXZ
import net.ccbluex.liquidbounce.utils.RotationUtils.getAngleDifference
import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation
import net.ccbluex.liquidbounce.utils.extensions.*
import net.ccbluex.liquidbounce.utils.misc.RandomUtils
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.ccbluex.liquidbounce.utils.timing.TimeUtils.randomDelay
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
import net.ccbluex.liquidbounce.value.IntegerValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.entity.EntityLivingBase
Expand All @@ -31,7 +33,10 @@ object SuperKnockback : Module("SuperKnockback", Category.COMBAT, hideModule = f
private val delay by IntegerValue("Delay", 0, 0..500)
private val hurtTime by IntegerValue("HurtTime", 10, 0..10)

private val mode by ListValue("Mode", arrayOf("SprintTap", "SprintTap2", "WTap", "Old", "Silent", "Packet", "SneakPacket"), "Old")
private val mode by ListValue("Mode",
arrayOf("WTap", "SprintTap", "SprintTap2", "Old", "Silent", "Packet", "SneakPacket"),
"Old"
)
private val maxTicksUntilBlock: IntegerValue = object : IntegerValue("MaxTicksUntilBlock", 2, 0..5) {
override fun isSupported() = mode == "WTap"

Expand Down Expand Up @@ -67,6 +72,8 @@ object SuperKnockback : Module("SuperKnockback", Category.COMBAT, hideModule = f
override fun onChange(oldValue: Int, newValue: Int) = newValue.coerceAtLeast(stopTicks.get())
}

private val minEnemyRotDiffToIgnore by FloatValue("MinRotationDiffFromEnemyToIgnore", 180f, 0f..180f)

private val onlyGround by BoolValue("OnlyGround", false)
val onlyMove by BoolValue("OnlyMove", true)
val onlyMoveForward by BoolValue("OnlyMoveForward", true) { onlyMove }
Expand Down Expand Up @@ -101,12 +108,18 @@ object SuperKnockback : Module("SuperKnockback", Category.COMBAT, hideModule = f
val target = event.targetEntity as? EntityLivingBase ?: return
val distance = player.getDistanceToEntityBox(target)

val rotationToPlayer = toRotation(player.hitBox.center, false, target).fixedSensitivity().yaw
val angleDifferenceToPlayer = getAngleDifference(rotationToPlayer, target.rotationYaw)

if (event.targetEntity.hurtTime > hurtTime || !timer.hasTimePassed(delay) || onlyGround && !player.onGround || RandomUtils.nextInt(
endExclusive = 100
) > chance) return

if (onlyMove && (!isMoving || onlyMoveForward && player.movementInput.moveStrafe != 0f)) return

// Is the enemy facing his back on us?
if (angleDifferenceToPlayer > minEnemyRotDiffToIgnore && !target.hitBox.isVecInside(player.eyes)) return

when (mode) {
"Old" -> {
// Users reported that this mode is better than the other ones
Expand Down Expand Up @@ -255,7 +268,6 @@ object SuperKnockback : Module("SuperKnockback", Category.COMBAT, hideModule = f
override val tag
get() = mode


fun breakSprint() = handleEvents() && forceSprintState == 2 && mode == "SprintTap"
fun startSprint() = handleEvents() && forceSprintState == 1 && mode == "SprintTap"
}
}