From f4cea3eb7de1ab3a947bb1e830b25267ec4f67f7 Mon Sep 17 00:00:00 2001 From: mems01 <70612656+mems01@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:20:13 +0200 Subject: [PATCH] killaura circle gradient colors/button color update --- .../module/modules/combat/KillAura.kt | 12 ++-- .../forge/mixins/gui/MixinGuiButton.java | 17 +++-- .../forge/mixins/gui/MixinGuiButtonExt.java | 17 +++-- .../forge/mixins/gui/MixinGuiSlot.java | 5 +- .../liquidbounce/utils/render/RenderUtils.kt | 66 ++++++++++--------- 5 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt index c78962bbded..e34f8d7be85 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt @@ -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 @@ -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() @@ -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 ) } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButton.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButton.java index 62f188f5bfc..49072b4b6cc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButton.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButton.java @@ -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); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButtonExt.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButtonExt.java index a3447800635..05127975267 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButtonExt.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiButtonExt.java @@ -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); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiSlot.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiSlot.java index bdcda16f124..d48d1d761f9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiSlot.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiSlot.java @@ -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_); diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt index 617021b85aa..69ab0e90716 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.kt @@ -238,10 +238,10 @@ object RenderUtils : MinecraftInstance { filled: Boolean, withHeight: Boolean, circleY: ClosedFloatingPointRange? = null, - color: Color + startColor: Int, + endColor: Int ) { val manager = mc.renderManager - val positions = mutableListOf() val renderX = manager.viewerPosX @@ -254,13 +254,22 @@ 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() @@ -268,51 +277,50 @@ object RenderUtils : MinecraftInstance { 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() @@ -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() @@ -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() @@ -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