Skip to content

Commit

Permalink
killaura circle gradient colors/button color update
Browse files Browse the repository at this point in the history
  • Loading branch information
mems01 committed Feb 17, 2025
1 parent 587b574 commit f4cea3e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import net.ccbluex.liquidbounce.utils.inventory.ItemUtils.isConsumingItem
import net.ccbluex.liquidbounce.utils.inventory.SilentHotbar
import net.ccbluex.liquidbounce.utils.kotlin.RandomUtils.nextInt
import net.ccbluex.liquidbounce.utils.render.ColorSettingsInteger
import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow
import net.ccbluex.liquidbounce.utils.render.ColorUtils.withAlpha
import net.ccbluex.liquidbounce.utils.render.RenderUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawCircle
Expand Down Expand Up @@ -294,12 +293,8 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {
private val aimPointBoxSize by float("AimPointBoxSize", 0.1f, 0f..0.2F) { renderAimPointBox }.subjective()

// Circle options
private val circleRainbow by boolean("CircleRainbow", false) { mark == "Circle" }.subjective()

// TODO: replace this with color value
private val colors = ColorSettingsInteger(
this, "CircleColor"
) { mark == "Circle" && !circleRainbow }.with(132, 102, 255, 100)//.subjective()
private val circleStartColor by color("CircleStartColor", Color.BLUE) { mark == "Circle" }.subjective()
private val circleEndColor by color("CircleEndColor", Color.CYAN.withAlpha(0)) { mark == "Circle" }.subjective()
private val fillInnerCircle by boolean("FillInnerCircle", false) { mark == "Circle" }.subjective()
private val withHeight by boolean("WithHeight", true) { mark == "Circle" }.subjective()
private val animateHeight by boolean("AnimateHeight", false) { withHeight }.subjective()
Expand Down Expand Up @@ -549,7 +544,8 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {
fillInnerCircle,
withHeight,
circleYRange.takeIf { animateCircleY },
if (circleRainbow) rainbow().withAlpha(colors.color().alpha) else colors.color()
circleStartColor.rgb,
circleEndColor.rgb
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,16 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {

float radius = 2.5F;

// Draw original
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, xPosition + width, yPosition + height, enabled ? new Color(0F, 0F, 0F, 120 / 255f).getRGB() : new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);

if (enabled && progress != xPosition) {
// Draw blue overlay
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, progress, yPosition + height, new Color(0F, 0F, 1F, 1F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);
}
RenderUtils.INSTANCE.withClipping(() -> {
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, xPosition + width, yPosition + height, enabled ? new Color(0F, 0F, 0F, 120 / 255f).getRGB() : new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);
return null;
}, () -> {
if (enabled && progress != xPosition) {
// Draw blue overlay
RenderUtils.INSTANCE.drawGradientRect(xPosition, yPosition, progress, yPosition + height, Color.CYAN.darker().getRGB(), Color.BLUE.darker().getRGB(), 0F);
}
return null;
}, false);

mc.getTextureManager().bindTexture(buttonTextures);
mouseDragged(mc, mouseX, mouseY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {

float radius = 2.5F;

// Draw original
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, xPosition + width, yPosition + height, enabled ? new Color(0F, 0F, 0F, 120 / 255f).getRGB() : new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);

if (enabled && progress != xPosition) {
// Draw blue overlay
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, progress, yPosition + height, new Color(0F, 0F, 1F, 1F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);
}
RenderUtils.INSTANCE.withClipping(() -> {
RenderUtils.INSTANCE.drawRoundedRect(xPosition, yPosition, xPosition + width, yPosition + height, enabled ? new Color(0F, 0F, 0F, 120 / 255f).getRGB() : new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB(), radius, RenderUtils.RoundedCorners.ALL);
return null;
}, () -> {
if (enabled && progress != xPosition) {
// Draw blue overlay
RenderUtils.INSTANCE.drawGradientRect(xPosition, yPosition, progress, yPosition + height, Color.CYAN.darker().getRGB(), Color.BLUE.darker().getRGB(), 0F);
}
return null;
}, false);

mc.getTextureManager().bindTexture(buttonTextures);
mouseDragged(mc, mouseX, mouseY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ private void injectClientDraw(int p_drawSelectionBox_1_, int p_drawSelectionBox_
int i1 = this.left + (this.width / 2 - this.getListWidth() / 2);
int j1 = this.left + this.width / 2 + this.getListWidth() / 2;

RenderUtils.INSTANCE.drawRoundedRect(i1 + 2, k, j1 - 1, k + l + 1, new Color(0, 0, 0, 100).getRGB(), 2F, RenderUtils.RoundedCorners.ALL);

RenderUtils.INSTANCE.drawRoundedBorder(i1 + 2, k + l + 1, j1 - 1, k + l + 1, 3F, Color.BLUE.getRGB(), 0F);
RenderUtils.INSTANCE.drawRoundedRect(i1 + 2, k, j1 - 1, k + l + 1, new Color(0, 0, 0, 100).getRGB(), 2F, RenderUtils.RoundedCorners.TOP_ONLY);
RenderUtils.INSTANCE.drawGradientRect(i1 + 2, k + l, j1 - 1, k + l + 1.5f, Color.CYAN.getRGB(), Color.BLUE.getRGB(), 0f);
}

this.drawSlot(j, p_drawSelectionBox_1_, k, l, p_drawSelectionBox_3_, p_drawSelectionBox_4_);
Expand Down
66 changes: 35 additions & 31 deletions src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ object RenderUtils : MinecraftInstance {
filled: Boolean,
withHeight: Boolean,
circleY: ClosedFloatingPointRange<Float>? = null,
color: Color
startColor: Int,
endColor: Int
) {
val manager = mc.renderManager

val positions = mutableListOf<DoubleArray>()

val renderX = manager.viewerPosX
Expand All @@ -254,65 +254,73 @@ object RenderUtils : MinecraftInstance {
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()

shadeModel(GL_SMOOTH)

val a1 = (startColor shr 24 and 255) / 255f
val r1 = (startColor shr 16 and 255) / 255f
val g1 = (startColor shr 8 and 255) / 255f
val b1 = (startColor and 255) / 255f
val a2 = (endColor shr 24 and 255) / 255f
val r2 = (endColor shr 16 and 255) / 255f
val g2 = (endColor shr 8 and 255) / 255f
val b2 = (endColor and 255) / 255f

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)

val tessellator = Tessellator.getInstance()
val buffer = tessellator.worldRenderer

if (filled) {
glBegin(GL_TRIANGLE_FAN)
glColor(color)
buffer.begin(GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR)
}

entity.interpolatedPosition(entity.prevPos).let { pos ->
circlePoints.forEach {
circlePoints.forEachIndexed { index, it ->
val p = pos + Vec3(it.x * width, it.y + animatedCircleY, it.z * width)

positions += doubleArrayOf(p.xCoord, p.yCoord, p.zCoord)

if (filled) {
glVertex3d(p.xCoord - renderX, p.yCoord - renderY, p.zCoord - renderZ)
buffer.pos(p.xCoord - renderX, p.yCoord - renderY, p.zCoord - renderZ).color(r1, g1, b1, a1)
.endVertex()
}
}
}

if (filled) {
glEnd()
glColor(Color.WHITE)
tessellator.draw()
}

if (withHeight) {
glBegin(GL_QUADS)
glColor(color)
buffer.begin(GL_QUADS, DefaultVertexFormats.POSITION_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)
buffer.pos(pos[0] - renderX, pos[1] - renderY, pos[2] - renderZ).color(r1, g1, b1, a1).endVertex()
buffer.pos(endPos[0] - renderX, endPos[1] - renderY, endPos[2] - renderZ).color(r1, g1, b1, a1)
.endVertex()
buffer.pos(endPos[0] - renderX, endPos[1] - renderY + animatedHeight, endPos[2] - renderZ)
.color(r2, g2, b2, a2).endVertex()
buffer.pos(pos[0] - renderX, pos[1] - renderY + animatedHeight, pos[2] - renderZ).color(r2, g2, b2, a2)
.endVertex()
}

glEnd()

glColor(Color.WHITE)
tessellator.draw()
}

glEnable(GL_CULL_FACE)
glEnable(GL_DEPTH_TEST)
shadeModel(GL_FLAT)
glDisable(GL_ALPHA_TEST)
glDisable(GL_LINE_SMOOTH)
glDisable(GL_BLEND)
glEnable(GL_CULL_FACE)
glEnable(GL_TEXTURE_2D)
glPopMatrix()
glPopAttrib()
Expand Down Expand Up @@ -346,9 +354,7 @@ object RenderUtils : MinecraftInstance {
val innerHue = ColorUtils.shiftHue(innerColor, (index / CIRCLE_STEPS).toInt())
glColor4f(innerHue.red / 255f, innerHue.green / 255f, innerHue.blue / 255f, innerColor.alpha / 255f)
glVertex3d(
position.xCoord - renderX + innerX,
position.yCoord - renderY,
position.zCoord - renderZ + innerZ
position.xCoord - renderX + innerX, position.yCoord - renderY, position.zCoord - renderZ + innerZ
)
}
glEnd()
Expand All @@ -361,9 +367,7 @@ object RenderUtils : MinecraftInstance {
val outerHue = ColorUtils.shiftHue(outerColor, (index / CIRCLE_STEPS).toInt())
glColor4f(outerHue.red / 255f, outerHue.green / 255f, outerHue.alpha / 255f, outerColor.alpha / 255f)
glVertex3d(
position.xCoord - renderX + outerX,
position.yCoord - renderY,
position.zCoord - renderZ + outerZ
position.xCoord - renderX + outerX, position.yCoord - renderY, position.zCoord - renderZ + outerZ
)
}
glEnd()
Expand Down Expand Up @@ -930,7 +934,7 @@ object RenderUtils : MinecraftInstance {
* @param endColor the end color
*/
fun drawGradientRect(
left: Int, top: Int, right: Int, bottom: Int, startColor: Int, endColor: Int, zLevel: Float
left: Number, top: Number, right: Number, bottom: Number, startColor: Int, endColor: Int, zLevel: Float
) {
val a1 = (startColor shr 24 and 255) / 255f
val r1 = (startColor shr 16 and 255) / 255f
Expand Down

0 comments on commit f4cea3e

Please sign in to comment.