Add a try and catch in the render function of ClickBox.kt.

This commit is contained in:
Username404-59 2021-04-12 23:44:15 +02:00
parent 25a37898ad
commit ad3fb8be7a
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 21 additions and 16 deletions

View File

@ -3,6 +3,7 @@ package fr.username404.snowygui.gui
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack
import fr.username404.snowygui.Snowy
import net.minecraft.client.Minecraft
import net.minecraft.network.chat.TranslatableComponent
import org.lwjgl.opengl.GL20
@ -16,6 +17,7 @@ class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? =
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
with(buffer) {
try {
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
// Render the header:
vertex(x, y + height, 0.0).colorEnd()
@ -34,6 +36,9 @@ class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? =
vertex(x + inclination, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
vertex(x + width, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
tessellator.end()
} catch (e: Error) {
Snowy.logs.error("Error caught when rendering a ClickBox: $e")
}
}
RenderSystem.enableTexture()
RenderSystem.disableBlend()