package fr.username404.snowygui.gui import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.Minecraft import net.minecraft.network.chat.TranslatableComponent import org.lwjgl.opengl.GL20 class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? = null): ColoredElement(x, y, 80, 10, 0x6C9E9D, 0.5F) { private companion object { const val inclination: Double = 2.5 } override fun render(poseStack: PoseStack?) { RenderSystem.disableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() with(buffer) { begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR) // Render the header: 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).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_COLOR) vertex(x + inclination, y + height, 0.0).colorEnd(0xF2F2FC) vertex(x + width, y + height, 0.0).colorEnd(0xF2F2FC) tessellator.end() } RenderSystem.enableTexture() RenderSystem.disableBlend() if ((name != null) && (poseStack != null)) { Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, TransparentColor) } } }