aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt
blob: 221cbd9a247c46979344f942b1058f22448e79c7 (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
package at.hannibal2.skyhanni.utils

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

object GuiRender {

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

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

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

        val offsetX = (200 - renderer.getStringWidth(textToRender.removeColorCodes())) / 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()
    }
}