Revert "Replace VertexConsumer.colorEnd() with a new ColoredElement.setColor() method."
This reverts commit a9825ac5ccdbdd5c17d7937e87d15c288fa562e3.
This commit is contained in:
parent
d978898fe2
commit
70b0772517
|
@ -16,25 +16,23 @@ class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? =
|
||||||
RenderSystem.enableBlend()
|
RenderSystem.enableBlend()
|
||||||
RenderSystem.defaultBlendFunc()
|
RenderSystem.defaultBlendFunc()
|
||||||
with(buffer) {
|
with(buffer) {
|
||||||
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION)
|
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
|
||||||
// Render the header:
|
// Render the header:
|
||||||
setColor()
|
vertex(x, y + height, 0.0).colorEnd()
|
||||||
vertex(x, y + height, 0.0).endVertex()
|
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||||
vertex(x + width + inclination, y + height, 0.0).endVertex()
|
vertex(x + width, y, 0.0).colorEnd()
|
||||||
vertex(x + width, y, 0.0).endVertex()
|
vertex(x + inclination, y, 0.0).colorEnd()
|
||||||
vertex(x + inclination, y, 0.0).endVertex()
|
|
||||||
|
|
||||||
// Render the box:
|
// Render the box:
|
||||||
val fullHeight = (y + height) + 80
|
val fullHeight = (y + height) + 80
|
||||||
vertex(x, fullHeight, 0.0).endVertex()
|
vertex(x, fullHeight, 0.0).colorEnd()
|
||||||
vertex(x + width + inclination, fullHeight, 0.0).endVertex()
|
vertex(x + width + inclination, fullHeight, 0.0).colorEnd()
|
||||||
vertex(x + width + inclination, y + height, 0.0).endVertex()
|
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||||
tessellator.end()
|
tessellator.end()
|
||||||
|
|
||||||
begin(GL20.GL_LINES, DefaultVertexFormat.POSITION)
|
begin(GL20.GL_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||||
setColor(0xF2F2FC, o = 1F)
|
vertex(x + inclination, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
|
||||||
vertex(x + inclination, y + height, 0.0).endVertex()
|
vertex(x + width, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
|
||||||
vertex(x + width, y + height, 0.0).endVertex()
|
|
||||||
tessellator.end()
|
tessellator.end()
|
||||||
}
|
}
|
||||||
RenderSystem.enableTexture()
|
RenderSystem.enableTexture()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package fr.username404.snowygui.gui
|
package fr.username404.snowygui.gui
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder
|
import com.mojang.blaze3d.vertex.BufferBuilder
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import com.mojang.blaze3d.vertex.Tesselator
|
import com.mojang.blaze3d.vertex.Tesselator
|
||||||
|
@ -30,7 +29,6 @@ abstract class Element(
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val color: Int, val opacity: Float) : Element(x, y, width, height) {
|
abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val color: Int, val opacity: Float) : Element(x, y, width, height) {
|
||||||
protected fun setColor(c: Int = color, o: Float = opacity): Unit = hextoRGB(c).run { @Suppress("DEPRECATION") RenderSystem.color4f(get(0), get(1), get(2), o) }
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TransparentColor: Int = -0x1
|
const val TransparentColor: Int = -0x1
|
||||||
@JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
|
@JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
|
||||||
|
@ -39,6 +37,7 @@ abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected fun VertexConsumer.colorEnd() = colorIt(color, opacity).endVertex()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hextoRGB(hex: Int): MutableList<Float> {
|
fun hextoRGB(hex: Int): MutableList<Float> {
|
||||||
|
|
Loading…
Reference in New Issue