diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-02-05 22:09:46 -0500 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-26 16:23:19 -0400 |
commit | a0588bc0fce38990f06e66b5be9c89417217408f (patch) | |
tree | 1657452eb0d0e80df463fe62965f6f67d67b3be2 /src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java | |
parent | 37ad3ca7aa844bf0db54e7ee21e35837fd3cbbc1 (diff) | |
download | Skyblocker-a0588bc0fce38990f06e66b5be9c89417217408f.tar.gz Skyblocker-a0588bc0fce38990f06e66b5be9c89417217408f.tar.bz2 Skyblocker-a0588bc0fce38990f06e66b5be9c89417217408f.zip |
24w05a/b
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java new file mode 100644 index 00000000..220dbf86 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java @@ -0,0 +1,30 @@ +package de.hysky.skyblocker.utils.render; + +import org.joml.Matrix4f; + +import net.minecraft.client.util.math.MatrixStack; + +/** + * Matrix helper methods + */ +public interface MatrixHelper { + + /** + * Copies the {@code matrix} into a new {@link Matrix4f}. This is necessary otherwise + * any transformations applied will affect other uses of the same matrix. + */ + static Matrix4f copyOf(Matrix4f matrix) { + return new Matrix4f(matrix); + } + + /** + * Creates a blank {@link MatrixStack} and sets it's position matrix to the supplied + * {@code positionMatrix}. + */ + static MatrixStack toStack(Matrix4f positionMatrix) { + MatrixStack matrices = new MatrixStack(); + matrices.peek().getPositionMatrix().set(positionMatrix); + + return matrices; + } +} |