aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-05-03 12:15:45 +0200
committerGitHub <noreply@github.com>2024-05-03 12:15:45 +0200
commit4a2ac4ca162d846dcc9a2a3227f963321fa4e22a (patch)
tree3bd7a448f61e58e02f1e81778a40aa3b964fd8b7 /src/main/java/at/hannibal2/skyhanni/utils
parent8d338540f3293b03acdd74f40a6c84a3cbedbded (diff)
downloadskyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.gz
skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.bz2
skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.zip
Backend: GuiContainerEvent.BeforeDraw (#1510)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt3
2 files changed, 42 insertions, 2 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()
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
index fc1b0f45f..6c1e0bd2e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils.renderables
import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor
import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressBarConfig
+import at.hannibal2.skyhanni.data.GuiData
import at.hannibal2.skyhanni.data.HighlightOnHoverSlot
import at.hannibal2.skyhanni.data.ToolTipData
import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager
@@ -231,7 +232,7 @@ interface Renderable {
}
val isGuiPositionEditor = Minecraft.getMinecraft().currentScreen !is GuiPositionEditor
val isNotInSignAndOnSlot = if (Minecraft.getMinecraft().currentScreen !is GuiEditSign) {
- ToolTipData.lastSlot == null
+ ToolTipData.lastSlot == null || GuiData.preDrawEventCanceled
} else true
val isConfigScreen = Minecraft.getMinecraft().currentScreen !is GuiScreenElementWrapper