Skip to content

Commit

Permalink
feats: Circle mark CombatVisuals (Circle) + Option suffix support.
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Dec 11, 2024
1 parent 223c5c5 commit 6ca98ad
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 151 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ object FlagCheck : Module("FlagCheck", Category.OTHER, gameDetecting = true, hid
this,
"Text",
zeroAlphaCheck = true,
alphaApply = true,
alphaApply = { true },
applyMax = true
) { renderServerPos == "Box" }

private val boxColors = ColorSettingsInteger(
this,
"Box",
zeroAlphaCheck = true,
alphaApply = true,
alphaApply = { true },
withAlpha = false
) { renderServerPos == "Box" }.with(r = 255, g = 255)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.modules.combat.Criticals
import net.ccbluex.liquidbounce.handler.combat.CombatManager
import net.ccbluex.liquidbounce.utils.extensions.withAlpha
import net.ccbluex.liquidbounce.utils.render.ColorSettingsInteger
import net.ccbluex.liquidbounce.utils.render.ColorUtils
import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawCircle
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawCrystal
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawEntityBox
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawEntityBoxESP
Expand Down Expand Up @@ -42,14 +46,27 @@ object CombatVisuals : Module("CombatVisuals", Category.VISUAL, hideModule = fal
}

// Mark - TargetESP
private val markValue by choices("MarkMode", arrayOf("None", "Zavz", "Jello", "Lies", "FDP", "Sims", "Box", "RoundBox", "Head", "Mark"), "Zavz")
private val markValue by choices("MarkMode", arrayOf("None", "Zavz", "Circle", "Jello", "Lies", "FDP", "Sims", "Box", "RoundBox", "Head", "Mark"), "Zavz")
private val isMarkMode: Boolean
get() = markValue != "None" && markValue != "Sims" && markValue != "FDP" && markValue != "Lies" && markValue != "Jello"

val colorRedValue by int("Mark-Red", 0, 0.. 255) { isMarkMode }
val colorGreenValue by int("Mark-Green", 160, 0..255) { isMarkMode }
val colorBlueValue by int("Mark-Blue", 255, 0.. 255) { isMarkMode }

private val circleRainbow by boolean("CircleRainbow", false, subjective = true) { markValue == "Circle" }
private val colors = ColorSettingsInteger(this, "Circle", alphaApply = { markValue == "Circle" })
{ markValue == "Circle" && !circleRainbow }.with(132, 102, 255, 100)
private val fillInnerCircle by boolean("FillInnerCircle", false, subjective = true) { markValue == "Circle" }
private val withHeight by boolean("WithHeight", true, subjective = true) { markValue == "Circle" }
private val animateHeight by boolean("AnimateHeight", false, subjective = true) { withHeight }
private val heightRange by floatRange("HeightRange", 0.0f..0.4f, -2f..2f, subjective = true) { withHeight }
private val extraWidth by float("ExtraWidth", 0F, 0F..2F, subjective = true) { markValue == "Circle" }
private val animateCircleY by boolean("AnimateCircleY", true, subjective = true) { fillInnerCircle || withHeight }
private val circleYRange by floatRange("CircleYRange", 0F..0.5F, 0F..2F, subjective = true) { animateCircleY }
private val duration by float("Duration", 1.5F, 0.5F..3F, suffix = "Seconds", subjective = true)
{ animateCircleY || animateHeight }

private val alphaValue by int("Alpha", 255, 0.. 255) { isMarkMode && markValue == "Zavz" && markValue == "Jello"}

val colorRedTwoValue by int("Mark-Red 2", 0, 0.. 255) { isMarkMode && markValue == "Zavz" }
Expand Down Expand Up @@ -154,6 +171,17 @@ object CombatVisuals : Module("CombatVisuals", Category.VISUAL, hideModule = fal
entityLivingBase,
event
)

"circle" -> drawCircle(
entityLivingBase,
duration * 1000F,
heightRange.takeIf { animateHeight } ?: heightRange.endInclusive..heightRange.endInclusive,
extraWidth,
fillInnerCircle,
withHeight,
circleYRange.takeIf { animateCircleY },
if (circleRainbow) rainbow().withAlpha(colors.color().alpha) else colors.color()
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.ccbluex.liquidbounce.injection.forge.mixins.gui;

import net.ccbluex.liquidbounce.utils.render.RenderUtils;
import net.ccbluex.liquidbounce.utils.render.animation.AnimationUtil;
import net.minecraft.client.gui.GuiTextField;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -37,9 +38,7 @@ private boolean injectClientDraw(GuiTextField instance) {

if (instance.isFocused()) {
// Some cool breathing effects
float progress = (System.currentTimeMillis() % 1500L) / (float) 1500L;
float breathingValue = 0.5f * (float) (Math.sin(2 * Math.PI * progress) + 1);
width = 1f + (4f - 1f) * breathingValue;
width = 1f + (4f - 1f) * AnimationUtil.INSTANCE.breathe(1500F);
}

RenderUtils.INSTANCE.drawRoundedBorder(this.xPosition, this.yPosition + height, this.xPosition + this.width, this.yPosition + height, width - 0.5F, Color.BLUE.getRGB(), radius - 1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ object BlackStyle : Style() {
for (value in moduleValues) {
assumeNonVolatile = value.get() is Number

val suffix = value.suffix ?: ""

when (value) {
is BoolValue -> {
val text = value.name
Expand Down Expand Up @@ -221,7 +223,7 @@ object BlackStyle : Style() {
}

is FloatValue -> {
val text = value.name + "§f: " + round(value.get())
val text = value.name + "§f: " + round(value.get()) + " §7$suffix"

moduleElement.settingsWidth = font35.getStringWidth(text) + 8

Expand Down Expand Up @@ -262,8 +264,11 @@ object BlackStyle : Style() {
}

is IntegerValue -> {
val text =
value.name + "§f: " + if (value is BlockValue) getBlockName(value.get()) + " (" + value.get() + ")" else value.get()
val text = value.name + "§f: " + if (value is BlockValue) {
getBlockName(value.get()) + " (" + value.get() + ")"
} else {
value.get()
} + " §7$suffix"

moduleElement.settingsWidth = font35.getStringWidth(text) + 8

Expand Down Expand Up @@ -303,7 +308,7 @@ object BlackStyle : Style() {
val slider1 = value.get().first
val slider2 = value.get().last

val text = "${value.name}§f: $slider1 - $slider2 (Beta)"
val text = "${value.name}§f: $slider1 - $slider2 §7$suffix§f (Beta)"
moduleElement.settingsWidth = font35.getStringWidth(text) + 8

val x = minX + 4
Expand Down Expand Up @@ -355,7 +360,7 @@ object BlackStyle : Style() {
val slider1 = value.get().start
val slider2 = value.get().endInclusive

val text = "${value.name}§f: ${round(slider1)} - ${round(slider2)} (Beta)"
val text = "${value.name}§f: ${round(slider1)} - ${round(slider2)} §7$suffix§f (Beta)"
moduleElement.settingsWidth = font35.getStringWidth(text) + 8

val x = minX + 4f
Expand All @@ -365,9 +370,9 @@ object BlackStyle : Style() {

if ((mouseButton == 0 || sliderValueHeld == value) && mouseX.toFloat() in x..x + width && mouseY.toFloat() in y - 2..y + 5) {
val slider1Pos =
minX + ((slider1 - value.minimum).toFloat() / (value.maximum - value.minimum)) * (maxX - minX)
minX + ((slider1 - value.minimum) / (value.maximum - value.minimum)) * (maxX - minX)
val slider2Pos =
minX + ((slider2 - value.minimum).toFloat() / (value.maximum - value.minimum)) * (maxX - minX)
minX + ((slider2 - value.minimum) / (value.maximum - value.minimum)) * (maxX - minX)

val distToSlider1 = mouseX - slider1Pos
val distToSlider2 = mouseX - slider2Pos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Text(x: Double = 10.0, y: Double = 10.0, scale: Float = 1F, side: Side = S
private val colors = ColorSettingsInteger(
this,
zeroAlphaCheck = true,
alphaApply = textColorMode != "Rainbow",
alphaApply = { textColorMode != "Rainbow" },
applyMax = true
) { textColorMode == "Custom" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class ColorSettingsFloat(owner: Any, name: String, val index: Int? = null, gener
private val r by float(
"$name-R${index ?: ""}",
if ((index ?: 0) % 3 == 1) 255f else 0f,
0f..255f
0f..255f, subjective = true
) { generalApply() }
private val g by float(
"$name-G${index ?: ""}",
if ((index ?: 0) % 3 == 2) 255f else 0f,
0f..255f
0f..255f, subjective = true
) { generalApply() }
private val b by float(
"$name-B${index ?: ""}",
if ((index ?: 0) % 3 == 0) 255f else 0f,
0f..255f
0f..255f, subjective = true
) { generalApply() }

fun color() = Color(r / 255f, g / 255f, b / 255f)
Expand All @@ -50,32 +50,32 @@ class ColorSettingsFloat(owner: Any, name: String, val index: Int? = null, gener

class ColorSettingsInteger(
owner: Any, name: String? = null, val index: Int? = null, withAlpha: Boolean = true,
zeroAlphaCheck: Boolean = false,
alphaApply: Boolean? = null, applyMax: Boolean = false, generalApply: () -> Boolean = { true },
zeroAlphaCheck: Boolean = false, applyMax: Boolean = false,
alphaApply: () -> Boolean? = { null }, generalApply: () -> Boolean = { true },
) {
private val string = if (name == null) "" else "$name-"
private val max = if (applyMax) 255 else 0

private var red = int(
"${string}R${index ?: ""}",
max,
0..255
0..255, subjective = true
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var green = int(
"${string}G${index ?: ""}",
max,
0..255
0..255, subjective = true
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var blue = int(
"${string}B${index ?: ""}",
max,
0..255
0..255, subjective = true
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var alpha = int(
"${string}Alpha${index ?: ""}",
255,
0..255
) { alphaApply ?: generalApply() && withAlpha }
0..255, subjective = true
) { alphaApply() ?: generalApply() && withAlpha }

private var r by red
private var g by green
Expand Down Expand Up @@ -117,7 +117,7 @@ class ColorSettingsInteger(
it,
withAlpha,
zeroAlphaCheck,
applyMax = applyMax
applyMax
) { generalApply(it) }
}
}
Expand Down
80 changes: 78 additions & 2 deletions src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.ccbluex.liquidbounce.utils.extensions.lastTickPos
import net.ccbluex.liquidbounce.utils.extensions.renderPos
import net.ccbluex.liquidbounce.utils.extensions.toRadians
import net.ccbluex.liquidbounce.utils.render.ColorUtils.setColour
import net.ccbluex.liquidbounce.utils.render.animation.AnimationUtil
import net.ccbluex.liquidbounce.utils.render.animation.AnimationUtil.easeInOutQuadX
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Gui
Expand Down Expand Up @@ -65,6 +66,12 @@ object RenderUtils : MinecraftInstance() {

fun deltaTimeNormalized(ticks: Int = 50) = (deltaTime / ticks.toDouble()).coerceAtMost(1.0)

private const val CIRCLE_STEPS = 40
val circlePoints = (0..CIRCLE_STEPS).map {
val theta = 2 * PI * it / CIRCLE_STEPS
Vec3(-sin(theta), 0.0, cos(theta))
}

init {
for (i in DISPLAY_LISTS_2D.indices) {
DISPLAY_LISTS_2D[i] = glGenLists(1)
Expand Down Expand Up @@ -163,6 +170,75 @@ object RenderUtils : MinecraftInstance() {
tessellator.draw()
}

fun drawCircle(
entity: EntityLivingBase,
speed: Float,
height: ClosedFloatingPointRange<Float>,
size: Float,
filled: Boolean,
withHeight: Boolean,
circleY: ClosedFloatingPointRange<Float>? = null,
color: Color
) {
val manager = mc.renderManager
val positions = mutableListOf<DoubleArray>()
val (renderX, renderY, renderZ) = Triple(manager.viewerPosX, manager.viewerPosY, manager.viewerPosZ)
glPushAttrib(GL_ALL_ATTRIB_BITS)
glPushMatrix()
glDisable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_LINE_SMOOTH)
glDisable(GL_DEPTH_TEST)
glDisable(GL_CULL_FACE)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.0f)
mc.entityRenderer.disableLightmap()
val breathingT = AnimationUtil.breathe(speed)
val entityHeight = (entity.hitBox.maxY - entity.hitBox.minY).toFloat()
val width = (mc.renderManager.getEntityRenderObject<Entity>(entity)?.shadowSize ?: 0.5F) + size
val animatedHeight = (0F..entityHeight).lerpWith(height.lerpWith(breathingT))
val animatedCircleY = (0F..entityHeight).lerpWith(circleY?.lerpWith(breathingT) ?: 0F)
if (filled) {
glBegin(GL_TRIANGLE_FAN)
glColor(color)
}
entity.interpolatedPosition(entity.prevPos).let { pos ->
circlePoints.forEach {
val p = pos + Vec3(it.xCoord * width, it.yCoord + animatedCircleY, it.zCoord * width)
positions += doubleArrayOf(p.xCoord, p.yCoord, p.zCoord)
if (filled) {
glVertex3d(p.xCoord - renderX, p.yCoord - renderY, p.zCoord - renderZ)
}
}
}
if (filled) {
glEnd()
glColor(Color.WHITE)
}
if (withHeight) {
glBegin(GL_QUADS)
glColor(color)
positions.forEachIndexed { index, pos ->
val endPos = positions.getOrNull(index + 1) ?: return@forEachIndexed
glVertex3d(pos[0] - renderX, pos[1] - renderY, pos[2] - renderZ)
glVertex3d(endPos[0] - renderX, endPos[1] - renderY, endPos[2] - renderZ)
glVertex3d(endPos[0] - renderX, endPos[1] - renderY + animatedHeight, endPos[2] - renderZ)
glVertex3d(pos[0] - renderX, pos[1] - renderY + animatedHeight, pos[2] - renderZ)
}
glEnd()
glColor(Color.WHITE)
}
glEnable(GL_CULL_FACE)
glEnable(GL_DEPTH_TEST)
glDisable(GL_ALPHA_TEST)
glDisable(GL_LINE_SMOOTH)
glDisable(GL_BLEND)
glEnable(GL_TEXTURE_2D)
glPopMatrix()
glPopAttrib()
}


fun drawEntityBox(entity: Entity, color: Color, outline: Boolean) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
Expand Down Expand Up @@ -1197,7 +1273,7 @@ object RenderUtils : MinecraftInstance() {
fun drawLoadingCircle(x: Float, y: Float) {
for (i in 0..3) {
val rot = (System.nanoTime() / 5000000 * i % 360).toInt()
drawCircle(x, y, (i * 10).toFloat(), rot - 180, rot)
drawCircleJump(x, y, (i * 10).toFloat(), rot - 180, rot)
}
}

Expand Down Expand Up @@ -2089,7 +2165,7 @@ object RenderUtils : MinecraftInstance() {
return floatArrayOf(newX1, newY1, newX2, newY2)
}

fun drawCircle(x: Float, y: Float, radius: Float, start: Int, end: Int) {
fun drawCircleJump(x: Float, y: Float, radius: Float, start: Int, end: Int) {
enableBlend()
disableTexture2D()
tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,9 @@ object AnimationUtil {
t = t / d - 1
return c * (t * t * ((s + 1) * t + s) + 1) + b
}

fun breathe(duration: Float): Float {
val progress = System.currentTimeMillis() % duration.toLong() / duration
return 0.5f * (sin(2 * Math.PI * progress) + 1).toFloat()
}
}
Loading

0 comments on commit 6ca98ad

Please sign in to comment.