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): added new curve value. And implemented it in killaura turnspeed. #3354

Closed
wants to merge 14 commits into from
Closed
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.RaycastUtils.raycastEntity
import net.ccbluex.liquidbounce.utils.RaycastUtils.runWithModifiedRaycastResult
import net.ccbluex.liquidbounce.utils.Rotation
import net.ccbluex.liquidbounce.utils.RotationUtils
import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.rotationDifference
import net.ccbluex.liquidbounce.utils.RotationUtils.getVectorForRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.isRotationFaced
import net.ccbluex.liquidbounce.utils.RotationUtils.isVisible
import net.ccbluex.liquidbounce.utils.RotationUtils.rotationDifference
import net.ccbluex.liquidbounce.utils.RotationUtils.searchCenter
import net.ccbluex.liquidbounce.utils.RotationUtils.serverRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation
import net.ccbluex.liquidbounce.utils.extensions.*
Expand All @@ -39,6 +42,7 @@ import net.ccbluex.liquidbounce.utils.render.RenderUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawEntityBox
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawPlatform
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.ccbluex.liquidbounce.utils.timing.TickTimer
import net.ccbluex.liquidbounce.utils.timing.TimeUtils.randomClickDelay
import net.ccbluex.liquidbounce.value.*
import net.minecraft.client.gui.inventory.GuiContainer
Expand All @@ -62,6 +66,7 @@ import net.minecraft.util.MovingObjectPosition
import net.minecraft.util.Vec3
import org.lwjgl.input.Keyboard
import java.awt.Color
import kotlin.collections.HashMap
import kotlin.math.max
import kotlin.math.roundToInt

Expand All @@ -70,6 +75,12 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R, hideModule
* OPTIONS
*/

private val rotationCurveBool by BoolValue("EnableRotationCurve",true)
private val rotationCurveValue = object: CurveValue("RotationCurve","Rotation Difference","Turn Speed", HashMap(),0f..180f,0f..180f,8){
override fun isSupported(): Boolean = rotationCurveBool
}
// private val rotationPathValue = object: CurveValue("RelativePitch", HashMap(),0f..180f,-90f..90f,8){}
// private val rotationCurve by rotationCurveValue
private val simulateCooldown by boolean("SimulateCooldown", false)
private val simulateDoubleClicking by boolean("SimulateDoubleClicking", false) { !simulateCooldown }

Expand Down Expand Up @@ -908,13 +919,35 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R, hideModule
return false
}

// println(runTimeTicks)
// val turnSpeed = currentRotation?.let { getRotationDifference(it, serverRotation) }

// rotation.yaw+= max(0f, quadratic(runTimeTicks%20).toFloat())

// println("RotationDifference: ${(getRotationDifference(serverRotation,rotation).toInt())}")
// println("RotationSpeed: ${(rotationCurveValue.getGeneratedY(getRotationDifference(serverRotation,rotation).toInt()))}")
var turnSpeed = options.horizontalSpeed to options.verticalSpeed
if (rotationCurveBool){
val getSpeedFromGraph = (rotationCurveValue.getGeneratedY(rotationDifference(serverRotation,rotation).toInt()))
turnSpeed = getSpeedFromGraph..getSpeedFromGraph + 3f to getSpeedFromGraph..getSpeedFromGraph + 2f
}
// val getRelativePitchFromGraph =(rotationPathValue.getGeneratedY(getAngleDifference(serverRotation.yaw,rotation.yaw).toInt()))
// currentRotation!!.pitch+=getRelativePitchFromGraph

setTargetRotation(rotation, options = options)

player.setPosAndPrevPos(currPos, oldPos)

return true
}

// private fun quadratic(x:Int): Double {
// val a = 1.0/1.5
// val b = 7.3
//
// val result = -(a * (x * x)) + (b * x)
// println(result)
// return result
// }
private fun ticksSinceClick() = runTimeTicks - (attackTickTimes.lastOrNull()?.second ?: 0)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.ccbluex.liquidbounce.utils.extensions.component1
import net.ccbluex.liquidbounce.utils.extensions.component2
import net.ccbluex.liquidbounce.utils.extensions.lerpWith
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBorderedRect
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawLine
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRect
import net.ccbluex.liquidbounce.value.*
import net.minecraft.client.gui.ScaledResolution
Expand Down Expand Up @@ -117,6 +118,83 @@ object LiquidBounceStyle : Style() {
assumeNonVolatile = value.get() is Number

when (value) {

is CurveValue -> {
var text = "§r" + value.name

val height = 77
val width = 148
val startY = 14
val finalY = startY+height
val xStartString = value.xRange.start.toInt().toString()
val xEndString = value.xRange.endInclusive.toInt().toString()
val yStartString = value.yRange.start.toInt().toString()
val yEndString = value.yRange.endInclusive.toInt().toString()
val textOffset = Math.max(font35.getStringWidth(xStartString), font35.getStringWidth(xEndString)) + 3
val leftX = minX + textOffset


//Background
drawRect(minX,yPos+2,maxX,yPos+finalY+ 3 * font35.fontHeight + 5, Int.MIN_VALUE)

//Draw Range
font35.drawString(xEndString, leftX - font35.getStringWidth(xEndString) - 1, yPos + startY, Color.WHITE.rgb)
font35.drawString(xStartString, leftX - font35.getStringWidth(xStartString) - 1, yPos + finalY-6, Color.WHITE.rgb)
font35.drawString(yStartString, leftX + 2, yPos + finalY+3, Color.WHITE.rgb)
font35.drawString(yEndString, leftX+width- font35.getStringWidth(yEndString), yPos + finalY+3, Color.WHITE.rgb)

//Draw Axis Name
font35.drawString("X-Axis: ${value.xAxisName}",minX+2,yPos+finalY+ font35.fontHeight+3,Color.WHITE.rgb)
font35.drawString("Y-Axis: ${value.yAxisName}",minX+2,yPos+finalY+ 2*font35.fontHeight+3,Color.WHITE.rgb)

//Graph Background
drawRect(leftX,yPos+startY,leftX+ width,yPos+ finalY,Color(71,71,71).rgb)

val points :ArrayList<Pair<Int,Int>> = ArrayList()
for(i in leftX ..leftX+ width step width /value.division){
var yCord = 0
val percentageX = ((i-leftX.toFloat())/width) //Value: 0 to 1 not technically percentage but shut up.
val valueX = ((percentageX * (value.xRange.endInclusive - value.xRange.start))+value.xRange.start).toInt()
if(value.getX(valueX)==null){
value.setX(valueX,0)
}else{
val actualYVal = value.getX(valueX)!!
val yPercentage = ((actualYVal - value.yRange.start)/( value.yRange.endInclusive-value.yRange.start))
yCord = ((yPercentage) * (height)).toInt()
}
//Line
drawRect(i+2,yPos+startY,i+3,yPos+ finalY,Color.gray.rgb)

//Box
// drawRect(i, yPos+ finalY -ycor,i + 5,yPos+ finalY -5-ycor, guiColor)
points.add(Pair(i+2,yPos+ finalY -3-yCord))
if ((mouseButton == 0 || sliderValueHeld == value)
&& mouseX in i..i+5
&& mouseY in yPos + startY..yPos + finalY
) {
val percentage = 1f-((mouseY- (yPos + startY.toFloat())) / (height.toFloat()))
val range = value.yRange.endInclusive-value.yRange.start
val graphY = ((percentage*range)+value.yRange.start).toInt()
println("Percentage: $percentage, Range: $range, GraphY: $graphY")
value.setX(valueX,graphY)
text +="§b $graphY"
// Keep changing this slider until mouse is unpressed.
sliderValueHeld = value

// Stop rendering and interacting only when this event was triggered by a mouse click.
if (mouseButton == 0) return true
}
}
for(i in 0..points.size-2){
drawLine(points[i].first.toDouble(),points[i].second.toDouble(),points[i+1].first.toDouble(),points[i+1].second.toDouble(),2f,Color.red.rgb)
}

font35.drawString(text, minX + 2, yPos + 4, Color.WHITE.rgb)

moduleElement.settingsWidth = width+textOffset+5

yPos += startY+height+ 3 * font35.fontHeight+3
}
is BoolValue -> {
val text = value.name

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@ object RenderUtils : MinecraftInstance() {
glEnable(GL_TEXTURE_2D)
}

fun drawLine(x: Double, y: Double, x1: Double, y1: Double, width: Float, color:Int) {
glDisable(GL_TEXTURE_2D)
glLineWidth(width)
glColor(color)
glBegin(GL_LINES)
glVertex2d(x, y)
glVertex2d(x1, y1)
glEnd()
glEnable(GL_TEXTURE_2D)
}
fun makeScissorBox(x: Float, y: Float, x2: Float, y2: Float) {
val scaledResolution = ScaledResolution(mc)
val factor = scaledResolution.scaleFactor
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/net/ccbluex/liquidbounce/value/Value.kt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,78 @@ open class FloatRangeValue(
get() = nextFloat(value.start, value.endInclusive)
}

/**
* Float value represents a value with a float
*/
open class CurveValue(
name: String,
val xAxisName:String,
val yAxisName: String,
value: HashMap<Int, Int>,
val xRange: ClosedFloatingPointRange<Float> = Float.MIN_VALUE..Float.MAX_VALUE,
val yRange: ClosedFloatingPointRange<Float> = Float.MIN_VALUE..Float.MAX_VALUE,
val division: Int,
subjective: Boolean = false,
isSupported: (() -> Boolean)? = null
) : Value<HashMap<Int, Int>>(name, value, subjective, isSupported) {


fun setX(x: Int, y: Int) {
value[x] = y
}

fun getX(x: Int): Int? {
return value[x]
}
fun getGeneratedY(x:Int):Float{
if (getX(x)!=null){
return getX(x)!!.toFloat()
}else if(value.keys.size>=division){
val keys = value.keys.sorted()
for (i in 0 until keys.size - 1) {
if (keys[i] <= x && x < keys[i + 1]) {
// println("$x is between ${keys[i]} and ${keys[i + 1]}")
val y1 = value[keys[i]]
val y2 = value[keys[i+1]]
val x1 = keys[i]
val x2 = keys[i+1]
val xCor = x - x1
val slope = (y2!!.toFloat()-y1!!)/(x2-x1)
// y = mx+c (Straight Line Formula) (We can use a different formula for a different style)
val yVal = slope * xCor + y1
return yVal
}
}
}
value[value.keys.maxOf { it }]

return value[value.keys.maxOf { it }]?.toFloat() ?: 0f
}

override fun toJsonF(): JsonElement? {
val jsonObject = JsonObject()
for ((key, v) in value) {
jsonObject.add(key.toString(), JsonPrimitive(v))
}
return jsonObject
}

override fun fromJsonF(element: JsonElement): HashMap<Int, Int>? {
return if (element.isJsonObject) {
val hashMap = HashMap<Int, Int>()
val jsonObject = element.asJsonObject
for ((key, value) in jsonObject.entrySet()) {
if (value.isJsonPrimitive && value.asJsonPrimitive.isNumber) {
hashMap[key.toInt()] = value.asInt
}
}
hashMap
} else {
null
}
}
}

/**
* Float value represents a value with a float
*/
Expand Down