aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/features/display/CatOverlay.kt
blob: 8f010ae395179f35405a87a080cbc7c321273410 (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 com.ambientaddons.features.display

import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
import com.ambientaddons.gui.GuiElement
import com.ambientaddons.gui.MoveGui
import com.ambientaddons.utils.render.OverlayUtils
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.roundToInt

object CatOverlay {
    private val cat = ResourceLocation("ambientaddons", "kittycatmodule.png")
    val element = GuiElement("cat", 100, 100)

    @SubscribeEvent
    fun onRenderOverlay(event: RenderGameOverlayEvent) {
        if ((!config.cat && mc.currentScreen !is MoveGui) ||
            event.type != RenderGameOverlayEvent.ElementType.TEXT
        ) return
        GlStateManager.pushMatrix()
        GlStateManager.enableAlpha()
        GlStateManager.color(255f, 255f, 255f, 255f)
        GlStateManager.translate(element.position.x, element.position.y, 500.0)
        mc.textureManager.bindTexture(cat)
        val renderSize = (100 * element.position.scale).roundToInt()
        OverlayUtils.drawTexturedModalRect(0, 0, renderSize, renderSize)
        GlStateManager.popMatrix()
    }
}