Fix and improve UI rendering
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
6eed08aa53
commit
5d98234d39
@ -81,27 +81,26 @@ class ClickBox(
|
|||||||
val currentHeight = y + (height + clickboxHeightOffset)
|
val currentHeight = y + (height + clickboxHeightOffset)
|
||||||
prepareDraw()
|
prepareDraw()
|
||||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
||||||
with(it) {
|
|
||||||
// Render the header:
|
// Render the header:
|
||||||
addVertex(x, y + height, 0.0F).colorEnd()
|
addVertex(x, y + height, 0.0F).colorEnd()
|
||||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||||
addVertex(x + width, y, 0.0F).colorEnd()
|
addVertex(x + width, y, 0.0F).colorEnd()
|
||||||
addVertex(x + inclination, y, 0.0F).colorEnd()
|
addVertex(x + inclination, y, 0.0F).colorEnd()
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
||||||
// Render the box:
|
// Render the box:
|
||||||
addVertex(x, currentHeight, 0.0F).colorEnd()
|
addVertex(x, currentHeight, 0.0F).colorEnd()
|
||||||
addVertex(x + width + inclination, currentHeight, 0.0F).colorEnd()
|
addVertex(x + width + inclination, currentHeight, 0.0F).colorEnd()
|
||||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||||
}
|
addVertex(x, y + height, 0.0F).colorEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
|
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
|
||||||
with(it) {
|
|
||||||
colorShader()
|
colorShader()
|
||||||
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||||
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
endDraw()
|
endDraw()
|
||||||
|
|
||||||
if (buttons.isNotEmpty()) {
|
if (buttons.isNotEmpty()) {
|
||||||
|
@ -18,7 +18,6 @@ import java.util.OptionalInt
|
|||||||
import java.util.OptionalDouble
|
import java.util.OptionalDouble
|
||||||
|
|
||||||
object RenderingUtil {
|
object RenderingUtil {
|
||||||
@JvmField val tessellator: Tesselator = Tesselator.getInstance()
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
||||||
setColor(get(0), get(1), get(2), opacity)
|
setColor(get(0), get(1), get(2), opacity)
|
||||||
@ -36,21 +35,21 @@ object RenderingUtil {
|
|||||||
fun drawRectangle(
|
fun drawRectangle(
|
||||||
x: Double, y: Double, height: Int, width: Int,
|
x: Double, y: Double, height: Int, width: Int,
|
||||||
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
||||||
): Unit = renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_QUADS) { buffer -> buffer.run {
|
): Unit = renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_QUADS) {
|
||||||
fun VertexConsumer.colorIt() = colorIt(color, opacity)
|
fun VertexConsumer.colorIt() = colorIt(color, opacity)
|
||||||
val x = x.toFloat() ; val y = y.toFloat()
|
val x = x.toFloat() ; val y = y.toFloat()
|
||||||
addVertex(x, y + height, 0.0F).colorIt()
|
addVertex(x, y + height, 0.0F).colorIt()
|
||||||
addVertex(x + width, y + height, 0.0F).colorIt()
|
addVertex(x + width, y + height, 0.0F).colorIt()
|
||||||
addVertex(x + width, y, 0.0F).colorIt()
|
addVertex(x + width, y, 0.0F).colorIt()
|
||||||
addVertex(x, y, 0.0F).colorIt()
|
addVertex(x, y, 0.0F).colorIt()
|
||||||
} }
|
}
|
||||||
|
|
||||||
fun renderBufferWithPipeline(
|
fun renderBufferWithPipeline(
|
||||||
name: String? = "Dynamic vertex buffer",
|
name: String? = "Dynamic vertex buffer",
|
||||||
renderPipeline: RenderPipeline,
|
renderPipeline: RenderPipeline,
|
||||||
renderTarget: RenderTarget = Minecraft.getInstance().mainRenderTarget,
|
renderTarget: RenderTarget = Minecraft.getInstance().mainRenderTarget,
|
||||||
uniformAndSamplerConsumer: ((RenderPass) -> Unit)? = null,
|
uniformAndSamplerConsumer: ((RenderPass) -> Unit)? = null,
|
||||||
bufferBuilderConsumer: (BufferBuilder) -> Unit,
|
bufferBuilderConsumer: BufferBuilder.() -> Unit,
|
||||||
) {
|
) {
|
||||||
val mode = renderPipeline.vertexFormatMode
|
val mode = renderPipeline.vertexFormatMode
|
||||||
val builder = Tesselator.getInstance().begin(mode, renderPipeline.vertexFormat)
|
val builder = Tesselator.getInstance().begin(mode, renderPipeline.vertexFormat)
|
||||||
|
Loading…
Reference in New Issue
Block a user