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(ElytraTarget): ElytraPvP module, utill for killaura #5690

Draft
wants to merge 3 commits into
base: nextgen
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 @@ -253,6 +253,7 @@ object ModuleManager : EventListener, Iterable<ClientModule> by modules {
ModuleAntiBot,
ModuleBetterTab,
ModuleBetterChat,
ModuleElytraTarget,
ModuleMiddleClickAction,
ModuleInventoryTracker,
ModuleNameProtect,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.tickHandler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura.getSpot
import net.ccbluex.liquidbounce.utils.aiming.PointTracker
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection
import net.ccbluex.liquidbounce.utils.client.Chronometer
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
import net.ccbluex.liquidbounce.utils.entity.squaredBoxedDistanceTo
import net.ccbluex.liquidbounce.utils.inventory.*
import net.ccbluex.liquidbounce.utils.kotlin.Priority
import net.minecraft.item.Items

private var fireworkCooldown = 750L

/**
* Выбирает цель и летит за ней на элитре.
* Работает в паре с киллаурой
*
* https://youtu.be/1wa8uKH_apY?si=H84DmdQ2HtvArIPZ
*
* @author sqlerrorthing
* @see ModuleKillaura.rotations
*/
@Suppress("MagicNumber", "NOTHING_TO_INLINE", "Unused", "UnusedPrivateProperty")
object ModuleElytraTarget : ClientModule("ElytraTarget", Category.COMBAT) {
private val autoFirework = tree(object : ToggleableConfigurable(this, "AutoFirework", true) {
val extraDistance by float("ExtraDistance", 50f, 5f..100f, suffix = "m")
val slotResetDelay by intRange("SlotResetDelay", 0..0, 0..20, "ticks")
})

private val rotations = tree(RotationsConfigurable(this, MovementCorrection.STRICT))
private val targetTracker = tree(TargetTracker())

override val running: Boolean
get() = super.running && player.isGliding

private inline val range get() = targetTracker.maxRange

private inline val fireworkSlot
get() = if (OffHandSlot.itemStack.item == Items.FIREWORK_ROCKET) {
OffHandSlot
} else {
Slots.Hotbar.findSlot(Items.FIREWORK_ROCKET)
}

private val fireworkChronometer = Chronometer()

@Suppress("unused")
private val targetUpdate = handler<RotationUpdateEvent> {
for (target in targetTracker.targets()) {
if (target.squaredBoxedDistanceTo(player) > range * range) {
continue
}

val spot = getSpot(target, range.toDouble(), PointTracker.AimSituation.FOR_NOW, false) ?: continue
val (rotation, vec) = spot

targetTracker.target = target
RotationManager.setRotationTarget(
rotations.toAimPlan(
rotation,
vec,
target,
considerInventory = true
),
priority = Priority.IMPORTANT_FOR_USAGE_3,
provider = this
)

return@handler
}

targetTracker.reset()
}

@Suppress("unused")
private val autoFireworkHandler = tickHandler {
val target = targetTracker.target ?: return@tickHandler

if (!autoFirework.enabled) {
return@tickHandler
}

if (fireworkChronometer.hasElapsed(fireworkCooldown)) {
val slot = fireworkSlot ?: return@tickHandler
useHotbarSlotOrOffhand(slot, autoFirework.slotResetDelay.random())

fireworkChronometer.reset()
}

val distance = autoFirework.extraDistance

fireworkCooldown = if (target.squaredBoxedDistanceTo(player) > distance * distance) {
300
} else {
200
}
}

override fun disable() {
targetTracker.reset()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {
val rotationTimingMode by enumChoice("RotationTiming", RotationTimingMode.NORMAL)
val aimThroughWalls by boolean("ThroughWalls", false)
})

private val pointTracker = tree(PointTracker())

// Bypass techniques
Expand Down Expand Up @@ -232,7 +233,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {

// Determine if we should attack the target or someone else
val rotation = if (rotations.rotationTimingMode == ON_TICK) {
getSpot(target, range.toDouble(), PointTracker.AimSituation.FOR_NOW)?.rotation
getSpot(target, range.toDouble(), PointTracker.AimSituation.FOR_NOW, rotations.aimThroughWalls)?.rotation
?: RotationManager.currentRotation ?: player.rotation
} else {
RotationManager.currentRotation ?: player.rotation
Expand Down Expand Up @@ -370,7 +371,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {
continue
}

val spot = getSpot(target, range.toDouble(), situation) ?: continue
val spot = getSpot(target, range.toDouble(), situation, rotations.aimThroughWalls) ?: continue

val ticks = rotations.howLongToReach(spot.rotation)
if (rotations.rotationTimingMode == SNAP && !clickScheduler.isClickOnNextTick(ticks.coerceAtLeast(1))
Expand Down Expand Up @@ -423,8 +424,12 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {
*
* @return The best spot to attack the entity
*/
private fun getSpot(entity: LivingEntity, range: Double,
situation: PointTracker.AimSituation): RotationWithVector? {
fun getSpot(
entity: LivingEntity,
range: Double,
situation: PointTracker.AimSituation,
aimThroughWalls: Boolean
): RotationWithVector? {
val point = pointTracker.gatherPoint(
entity,
situation
Expand Down Expand Up @@ -455,7 +460,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {
rotationPreference = rotationPreference
)

return if (spot == null && rotations.aimThroughWalls) {
return if (spot == null && aimThroughWalls) {
val throughSpot = raytraceBox(
eyes, point.cutOffBox,
// Since [range] is squared, we need to square root
Expand Down
Loading