aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt
blob: 014960e7afbc9a62e50b25e53f6f5e16f7b6e645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package at.hannibal2.skyhanni.utils

import at.hannibal2.skyhanni.config.gui.core.config.Position
import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.renderer.GlStateManager

object GuiRender {

    fun Position.renderString(string: String) {
        if (string == "") return
        val textToRender = "§f$string"

        GlStateManager.pushMatrix()
        val resolution = ScaledResolution(Minecraft.getMinecraft())

        val renderer = Minecraft.getMinecraft().renderManager.fontRenderer

        val offsetX = (200 - renderer.getStringWidth(textToRender.removeColor())) / 2

        val x = getAbsX(resolution, 200) + offsetX
        val y = getAbsY(resolution, 16)



        GlStateManager.translate(x + 1.0, y + 1.0, 0.0)
        renderer.drawStringWithShadow(textToRender, 0f, 0f, 0)


        GlStateManager.popMatrix()
    }
}