diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-05-03 12:15:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 12:15:45 +0200 |
commit | 4a2ac4ca162d846dcc9a2a3227f963321fa4e22a (patch) | |
tree | 3bd7a448f61e58e02f1e81778a40aa3b964fd8b7 /src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt | |
parent | 8d338540f3293b03acdd74f40a6c84a3cbedbded (diff) | |
download | skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.gz skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.bz2 skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.zip |
Backend: GuiContainerEvent.BeforeDraw (#1510)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt | 41 |
1 files changed, 40 insertions, 1 deletions
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() + } } |