aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/render
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-01 21:31:48 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-02 19:43:00 +0100
commit3bfec3033e9d905514d5c1c6c62953c2a1646af0 (patch)
treeafee0b3c20d0bdef9780e5fddb368c9d58fb3c70 /src/main/kotlin/moe/nea/firmament/util/render
parentf28dee0ef3a0dd4a0819a3d3a1c800a83a0f07f5 (diff)
downloadfirmament-3bfec3033e9d905514d5c1c6c62953c2a1646af0.tar.gz
firmament-3bfec3033e9d905514d5c1c6c62953c2a1646af0.tar.bz2
firmament-3bfec3033e9d905514d5c1c6c62953c2a1646af0.zip
Add mob drop viewer to item list
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/render')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/render/TranslatedScissors.kt27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/render/TranslatedScissors.kt b/src/main/kotlin/moe/nea/firmament/util/render/TranslatedScissors.kt
new file mode 100644
index 0000000..8f80f1b
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/util/render/TranslatedScissors.kt
@@ -0,0 +1,27 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.util.render
+
+import org.joml.Vector4f
+import net.minecraft.client.gui.DrawContext
+
+fun DrawContext.enableScissorWithTranslation(x1: Float, y1: Float, x2: Float, y2: Float) {
+ val pMat = matrices.peek().positionMatrix
+ val target = Vector4f()
+
+ target.set(x1, y1, 0f, 1f)
+ target.mul(pMat)
+ val scissorX1 = target.x
+ val scissorY1 = target.y
+
+ target.set(x2, y2, 0f, 1f)
+ target.mul(pMat)
+ val scissorX2 = target.x
+ val scissorY2 = target.y
+
+ enableScissor(scissorX1.toInt(), scissorY1.toInt(), scissorX2.toInt(), scissorY2.toInt())
+}