summaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/identifierutil.kt11
-rw-r--r--src/main/kotlin/util/render/ScreenRenderUtils.kt39
2 files changed, 50 insertions, 0 deletions
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()
+ }
+}