From 5aa969979ab1dd0e64e5b569cc3b7b281b3e536f Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 19 Oct 2024 18:20:55 +0200 Subject: Fix tick event and texture rendering --- src/main/kotlin/util/identifierutil.kt | 11 +++++++ src/main/kotlin/util/render/ScreenRenderUtils.kt | 39 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/kotlin/util/identifierutil.kt create mode 100644 src/main/kotlin/util/render/ScreenRenderUtils.kt (limited to 'src/main/kotlin/util') diff --git a/src/main/kotlin/util/identifierutil.kt b/src/main/kotlin/util/identifierutil.kt new file mode 100644 index 0000000..e94e15c --- /dev/null +++ b/src/main/kotlin/util/identifierutil.kt @@ -0,0 +1,11 @@ +package moe.nea.ultranotifier.util + +import moe.nea.ultranotifier.Constants +import net.minecraft.util.Identifier + +fun identifier(namespace: String, path: String): Identifier { + return Identifier(namespace, path) +} + +fun vanillaIdentifier(path: String) = identifier("minecraft", path) +fun ultraIdentifier(path: String) = identifier(Constants.MOD_ID, path) diff --git a/src/main/kotlin/util/render/ScreenRenderUtils.kt b/src/main/kotlin/util/render/ScreenRenderUtils.kt new file mode 100644 index 0000000..6a659bf --- /dev/null +++ b/src/main/kotlin/util/render/ScreenRenderUtils.kt @@ -0,0 +1,39 @@ +package moe.nea.ultranotifier.util.render + +import gg.essential.universal.UGraphics +import gg.essential.universal.UMatrixStack +import net.minecraft.util.Identifier +import java.awt.Color + +object ScreenRenderUtils { + fun fillRect( + matrixStack: UMatrixStack, + left: Double, top: Double, + right: Double, bottom: Double, + color: Color, + ) { + val buffer = UGraphics.getFromTessellator() + buffer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_COLOR) + buffer.pos(matrixStack, left, top, 0.0).color(color).endVertex() + buffer.pos(matrixStack, left, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, top, 0.0).color(color).endVertex() + buffer.drawDirect() + } + + fun renderTexture( + identifier: Identifier, + matrixStack: UMatrixStack, + left: Double, top: Double, + right: Double, bottom: Double, + ) { + UGraphics.bindTexture(0, identifier) + val graphics = UGraphics.getFromTessellator() + graphics.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE) + graphics.pos(matrixStack, left, top, 0.0).tex(0.0, 0.0).endVertex() + graphics.pos(matrixStack, left, bottom, 0.0).tex(0.0, 1.0).endVertex() + graphics.pos(matrixStack, right, bottom, 0.0).tex(1.0, 1.0).endVertex() + graphics.pos(matrixStack, right, top, 0.0).tex(1.0, 0.0).endVertex() + graphics.drawDirect() + } +} -- cgit