blob: f8e8f37dae2752f260c0153cd2a3590500e6c445 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.ConfigUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class RenderData {
@SubscribeEvent
fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) {
if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return
if (!canRender()) return
if (!SkyHanniDebugsAndTests.globalRender) return
if (GuiEditManager.isInGui() || VisualWordGui.isInGui()) return
GlStateManager.translate(0f, 0f, -3f)
GuiRenderEvent.GuiOverlayRenderEvent().postAndCatch()
GlStateManager.translate(0f, 0f, 3f)
}
@SubscribeEvent
fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) {
if (!canRender()) return
if (!SkyHanniDebugsAndTests.globalRender) return
if (GuiEditManager.isInGui() || VisualWordGui.isInGui()) return
val currentScreen = Minecraft.getMinecraft().currentScreen ?: return
if (currentScreen !is GuiInventory && currentScreen !is GuiChest) return
GlStateManager.pushMatrix()
GlStateManager.enableDepth()
if (GuiEditManager.isInGui()) {
GlStateManager.translate(0f, 0f, -3f)
GuiRenderEvent.GuiOverlayRenderEvent().postAndCatch()
GlStateManager.translate(0f, 0f, 3f)
}
GuiRenderEvent.ChestGuiOverlayRenderEvent().postAndCatch()
GlStateManager.popMatrix()
}
private fun canRender(): Boolean = Minecraft.getMinecraft()?.renderManager?.fontRenderer != null
@SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!SkyHanniDebugsAndTests.globalRender) return
LorenzRenderWorldEvent(event.partialTicks).postAndCatch()
}
// TODO find better spot for this
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.transform(17, "chroma.chromaDirection") { element ->
ConfigUtils.migrateIntToEnum(element, ChromaConfig.Direction::class.java)
}
}
}
|