aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-08 17:52:10 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-08 17:52:10 +0100
commitf6f8fef556e74f24187ad2a6296f573024a378b3 (patch)
treee6d8873e15e88c23d42b8634dad7179fbd198eec /src/main/kotlin
parent06534f9d09732ed29a6fa6bc48def5f7c2b0b865 (diff)
downloadFirmament-f6f8fef556e74f24187ad2a6296f573024a378b3.tar.gz
Firmament-f6f8fef556e74f24187ad2a6296f573024a378b3.tar.bz2
Firmament-f6f8fef556e74f24187ad2a6296f573024a378b3.zip
Fix line renderer
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/events/DebugInstantiateEvent.kt9
-rw-r--r--src/main/kotlin/util/render/FirmamentShaders.kt20
2 files changed, 26 insertions, 3 deletions
diff --git a/src/main/kotlin/events/DebugInstantiateEvent.kt b/src/main/kotlin/events/DebugInstantiateEvent.kt
new file mode 100644
index 0000000..3470a8c
--- /dev/null
+++ b/src/main/kotlin/events/DebugInstantiateEvent.kt
@@ -0,0 +1,9 @@
+package moe.nea.firmament.events
+
+/**
+ * Called in a devenv after minecraft has been initialized. This event should be used to force instantiation of lazy
+ * variables (and similar late init) to cause any possible issues to materialize.
+ */
+class DebugInstantiateEvent : FirmamentEvent() {
+ companion object : FirmamentEventBus<DebugInstantiateEvent>()
+}
diff --git a/src/main/kotlin/util/render/FirmamentShaders.kt b/src/main/kotlin/util/render/FirmamentShaders.kt
index 5147088..ba67dbb 100644
--- a/src/main/kotlin/util/render/FirmamentShaders.kt
+++ b/src/main/kotlin/util/render/FirmamentShaders.kt
@@ -3,14 +3,28 @@ package moe.nea.firmament.util.render
import net.minecraft.client.gl.Defines
import net.minecraft.client.gl.ShaderProgramKey
import net.minecraft.client.render.RenderPhase
+import net.minecraft.client.render.VertexFormat
import net.minecraft.client.render.VertexFormats
import moe.nea.firmament.Firmament
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.events.DebugInstantiateEvent
+import moe.nea.firmament.util.MC
object FirmamentShaders {
+ val shaders = mutableListOf<ShaderProgramKey>()
+ private fun shader(name: String, format: VertexFormat, defines: Defines): ShaderProgramKey {
+ val key = ShaderProgramKey(Firmament.identifier(name), format, defines)
+ shaders.add(key)
+ return key
+ }
- val _LINES: ShaderProgramKey =
- ShaderProgramKey(Firmament.identifier("rendertype_lines"), VertexFormats.LINES, Defines.EMPTY)
- val LINES = RenderPhase.ShaderProgram(_LINES)
+ val LINES = RenderPhase.ShaderProgram(shader("core/rendertype_lines", VertexFormats.LINES, Defines.EMPTY))
+ @Subscribe
+ fun debugLoad(event: DebugInstantiateEvent) {
+ shaders.forEach {
+ MC.instance.shaderLoader.getOrCreateProgram(it)
+ }
+ }
}