From 4a2ac4ca162d846dcc9a2a3227f963321fa4e22a Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Fri, 3 May 2024 12:15:45 +0200 Subject: Backend: GuiContainerEvent.BeforeDraw (#1510) --- .../at/hannibal2/skyhanni/utils/GuiRenderUtils.kt | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt index aab61ab10..8962e402e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt @@ -9,6 +9,8 @@ import net.minecraft.client.gui.FontRenderer import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper +import net.minecraft.client.renderer.Tessellator +import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.item.ItemStack import org.lwjgl.opengl.GL11 import java.awt.Color @@ -310,7 +312,7 @@ object GuiRenderUtils { color: Color, useChroma: Boolean, texture: SkillProgressBarConfig.TexturedBar.UsedTexture, - height: Float + height: Float, ) { GlStateManager.pushMatrix() GlStateManager.translate(x, y, 0f) @@ -377,4 +379,41 @@ object GuiRenderUtils { } GlStateManager.popMatrix() } + + /**@Mojang */ + fun drawGradientRect( + left: Int, + top: Int, + right: Int, + bottom: Int, + startColor: Int, + endColor: Int, + zLevel: Double, + ) { + val f = (startColor shr 24 and 255).toFloat() / 255.0f + val g = (startColor shr 16 and 255).toFloat() / 255.0f + val h = (startColor shr 8 and 255).toFloat() / 255.0f + val i = (startColor and 255).toFloat() / 255.0f + val j = (endColor shr 24 and 255).toFloat() / 255.0f + val k = (endColor shr 16 and 255).toFloat() / 255.0f + val l = (endColor shr 8 and 255).toFloat() / 255.0f + val m = (endColor and 255).toFloat() / 255.0f + GlStateManager.disableTexture2D() + GlStateManager.enableBlend() + GlStateManager.disableAlpha() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.shadeModel(7425) + val tessellator = Tessellator.getInstance() + val worldRenderer = tessellator.worldRenderer + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) + worldRenderer.pos(right.toDouble(), top.toDouble(), zLevel).color(g, h, i, f).endVertex() + worldRenderer.pos(left.toDouble(), top.toDouble(), zLevel).color(g, h, i, f).endVertex() + worldRenderer.pos(left.toDouble(), bottom.toDouble(), zLevel).color(k, l, m, j).endVertex() + worldRenderer.pos(right.toDouble(), bottom.toDouble(), zLevel).color(k, l, m, j).endVertex() + tessellator.draw() + GlStateManager.shadeModel(7424) + GlStateManager.disableBlend() + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + } } -- cgit