Skip to content

Commit

Permalink
fix(CrystalAura): wrong setting sorting (#5624)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccetl authored Feb 15, 2025
1 parent fb5ff2e commit 9362fd3
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.crystalaura.trigg
import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld
import net.ccbluex.liquidbounce.utils.aiming.NoRotationMode
import net.ccbluex.liquidbounce.utils.aiming.NormalRotationMode
import net.ccbluex.liquidbounce.utils.client.FloatValueProvider
import net.ccbluex.liquidbounce.utils.combat.CombatManager
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
import net.ccbluex.liquidbounce.utils.kotlin.Priority
Expand All @@ -51,7 +52,9 @@ object ModuleCrystalAura : ClientModule(
disableOnQuit = true
) {

val targetTracker = tree(TargetTracker(range = float("Range", 4.5f, 1f..12f)))
val targetTracker = tree(TargetTracker(
rangeValue = FloatValueProvider("Range", 4.5f, 1f..12f)
))

object PredictFeature : Configurable("Predict") {
init {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.utils.client

import net.ccbluex.liquidbounce.config.types.Configurable
import net.ccbluex.liquidbounce.config.types.RangedValue

/**
* Provides a ranged value to a submodule.
* This has the advantage that the value can be either registered in the module or in the submodule.
*/
sealed interface RangedValueProvider {

/**
* Offers the provider to register to the configurable.
*
* @return The ranged value.
*/
fun register(offeredConfigurable: Configurable): RangedValue<*>?

}

/**
* Just returns the [value]; expects the value to be already registered elsewhere.
*/
class DummyRangedValueProvider(private val value: RangedValue<*>) : RangedValueProvider {

override fun register(offeredConfigurable: Configurable) = value

}

/**
* Does nothing; Has no value.
*/
data object NoneRangedValueProvider : RangedValueProvider {

override fun register(offeredConfigurable: Configurable) = null

}

/**
* [Configurable.float] registered to the submodule directly.
*/
class FloatValueProvider(
val name: String,
val default: Float,
val range: ClosedFloatingPointRange<Float>,
val suffix: String = ""
) : RangedValueProvider {

override fun register(offeredConfigurable: Configurable) : RangedValue<*> {
return offeredConfigurable.float(name, default, range, suffix)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import net.ccbluex.liquidbounce.config.types.NamedChoice
import net.ccbluex.liquidbounce.config.types.RangedValue
import net.ccbluex.liquidbounce.config.types.ValueType.*
import net.ccbluex.liquidbounce.utils.aiming.RotationUtil
import net.ccbluex.liquidbounce.utils.client.player
import net.ccbluex.liquidbounce.utils.client.world
import net.ccbluex.liquidbounce.utils.client.*
import net.ccbluex.liquidbounce.utils.entity.getActualHealth
import net.ccbluex.liquidbounce.utils.entity.squaredBoxedDistanceTo
import net.ccbluex.liquidbounce.utils.math.sq
Expand All @@ -37,8 +36,11 @@ import net.minecraft.entity.player.PlayerEntity
*/
class TargetTracker(
defaultPriority: TargetPriority = TargetPriority.HEALTH,
range: RangedValue<*>? = null
) : TargetSelector(defaultPriority, range) {
rangeValue: RangedValueProvider = NoneRangedValueProvider
) : TargetSelector(defaultPriority, rangeValue) {

constructor(defaultPriority: TargetPriority = TargetPriority.HEALTH, range: RangedValue<*>) :
this(defaultPriority, DummyRangedValueProvider(range))

var target: LivingEntity? = null

Expand Down Expand Up @@ -75,11 +77,15 @@ class TargetTracker(

open class TargetSelector(
defaultPriority: TargetPriority = TargetPriority.HEALTH,
val range: RangedValue<*>? = null
rangeValue: RangedValueProvider = NoneRangedValueProvider
) : Configurable("Target") {

constructor(defaultPriority: TargetPriority = TargetPriority.HEALTH, range: RangedValue<*>) :
this(defaultPriority, DummyRangedValueProvider(range))

var closestSquaredEnemyDistance: Double = 0.0

private val range = rangeValue.register(this)
private val fov by float("FOV", 180f, 0f..180f)
private val hurtTime by int("HurtTime", 10, 0..10)
private val priority by enumChoice("Priority", defaultPriority)
Expand Down

0 comments on commit 9362fd3

Please sign in to comment.