Revert "Replace VertexConsumer.colorEnd() with a new ColoredElement.setColor() method."

This reverts commit a9825ac5ccdbdd5c17d7937e87d15c288fa562e3.
This commit is contained in:
Username404-59 2021-04-15 22:08:25 +02:00
parent d978898fe2
commit 70b0772517
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 12 additions and 15 deletions

View File

@ -16,25 +16,23 @@ class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? =
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
with(buffer) {
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION)
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
// Render the header:
setColor()
vertex(x, y + height, 0.0).endVertex()
vertex(x + width + inclination, y + height, 0.0).endVertex()
vertex(x + width, y, 0.0).endVertex()
vertex(x + inclination, y, 0.0).endVertex()
vertex(x, y + height, 0.0).colorEnd()
vertex(x + width + inclination, y + height, 0.0).colorEnd()
vertex(x + width, y, 0.0).colorEnd()
vertex(x + inclination, y, 0.0).colorEnd()
// Render the box:
val fullHeight = (y + height) + 80
vertex(x, fullHeight, 0.0).endVertex()
vertex(x + width + inclination, fullHeight, 0.0).endVertex()
vertex(x + width + inclination, y + height, 0.0).endVertex()
vertex(x, fullHeight, 0.0).colorEnd()
vertex(x + width + inclination, fullHeight, 0.0).colorEnd()
vertex(x + width + inclination, y + height, 0.0).colorEnd()
tessellator.end()
begin(GL20.GL_LINES, DefaultVertexFormat.POSITION)
setColor(0xF2F2FC, o = 1F)
vertex(x + inclination, y + height, 0.0).endVertex()
vertex(x + width, y + height, 0.0).endVertex()
begin(GL20.GL_LINES, DefaultVertexFormat.POSITION_COLOR)
vertex(x + inclination, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
vertex(x + width, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
tessellator.end()
}
RenderSystem.enableTexture()

View File

@ -1,6 +1,5 @@
package fr.username404.snowygui.gui
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.BufferBuilder
import com.mojang.blaze3d.vertex.PoseStack
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) {
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 {
const val TransparentColor: Int = -0x1
@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> {