diff options
author | Linnea Gräf <nea@nea.moe> | 2024-09-07 14:44:43 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-09-07 14:44:43 +0200 |
commit | 26461deda4dc8695dacedefe50d976eb5e3d7714 (patch) | |
tree | c079a8c2330df05037f944d6d7068b9ea39ebc24 /src/main/kotlin/events/RegisterCustomShadersEvent.kt | |
parent | 9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb (diff) | |
download | Firmament-26461deda4dc8695dacedefe50d976eb5e3d7714.tar.gz Firmament-26461deda4dc8695dacedefe50d976eb5e3d7714.tar.bz2 Firmament-26461deda4dc8695dacedefe50d976eb5e3d7714.zip |
Add shader loading functionality
[no changelog]
Diffstat (limited to 'src/main/kotlin/events/RegisterCustomShadersEvent.kt')
-rw-r--r-- | src/main/kotlin/events/RegisterCustomShadersEvent.kt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/kotlin/events/RegisterCustomShadersEvent.kt b/src/main/kotlin/events/RegisterCustomShadersEvent.kt new file mode 100644 index 0000000..2f6d1f8 --- /dev/null +++ b/src/main/kotlin/events/RegisterCustomShadersEvent.kt @@ -0,0 +1,24 @@ +package moe.nea.firmament.events + +import com.mojang.datafixers.util.Pair +import java.util.function.Consumer +import net.minecraft.client.gl.ShaderProgram +import net.minecraft.client.render.VertexFormat +import net.minecraft.resource.ResourceFactory +import moe.nea.firmament.Firmament + +data class RegisterCustomShadersEvent( + val list: MutableList<Pair<ShaderProgram, Consumer<ShaderProgram>>>, + val resourceFactory: ResourceFactory, +) : FirmamentEvent() { + companion object : FirmamentEventBus<RegisterCustomShadersEvent>() + + fun register(name: String, vertexFormat: VertexFormat, saver: Consumer<ShaderProgram>) { + require(name.startsWith("firmament_")) + try { + list.add(Pair.of(ShaderProgram(resourceFactory, name, vertexFormat), saver)) + } catch (ex: Exception) { + Firmament.logger.fatal("Could not load firmament shader $name", ex) + } + } +} |