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

This reverts commit 56896651a3622194660d57c733ab55be841b56b8.
This commit is contained in:
Username404-59 2021-04-13 10:48:37 +02:00
parent 5df5199098
commit 6f5ef9dace
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1

View File

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