aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chattils/utils/ModCompatHooks.kt
blob: 65c80f02a741cf6411a4fffe73c26dd6bf3f8636 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
package cc.woverflow.chattils.utils

import club.sk1er.patcher.config.PatcherConfig
import com.llamalad7.betterchat.BetterChat
import cc.woverflow.chattils.Chattils.isBetterChat
import cc.woverflow.chattils.Chattils.isPatcher
import cc.woverflow.chattils.config.ChattilsConfig.textRenderType
import cc.woverflow.chattils.utils.RenderHelper.drawBorderedString
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer

// This exists because mixin doesn't like dummy classes
object ModCompatHooks {
    @JvmStatic
    val xOffset
        get() = if (isBetterChat) BetterChat.getSettings().xOffset else 0

    @JvmStatic
    val yOffset
        get() = if (isBetterChat) BetterChat.getSettings().yOffset else 0

    @JvmStatic
    val chatPosition
        get() = if (isPatcher && PatcherConfig.chatPosition) 12 else 0

    @JvmStatic
    val extendedChatLength
        get() = if (isPatcher) 32667 else 0

    @JvmStatic
    val fontRenderer: FontRenderer
        get() = Minecraft.getMinecraft().fontRendererObj

    @JvmStatic
    fun redirectDrawString(text: String, x: Float, y: Float, color: Int): Int {
        return when (textRenderType) {
            0 -> {
                fontRenderer.drawString(text, x, y, color, false)
            }
            2 -> {
                drawBorderedString(fontRenderer, text, x.toInt(), y.toInt(), color)
            }
            else -> fontRenderer.drawString(text, x, y, color, true)
        }
    }
}