aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index d40f98667..53a228625 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -18,6 +18,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.gui.Gui
import net.minecraft.client.gui.ScaledResolution
+import net.minecraft.client.renderer.GLAllocation
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
@@ -48,10 +49,13 @@ object RenderUtils {
return value
}
}
+
enum class VerticalAlignment { TOP, CENTER, BOTTOM }
private val beaconBeam = ResourceLocation("textures/entity/beacon_beam.png")
+ private val matrixBuffer = GLAllocation.createDirectFloatBuffer(16);
+
infix fun Slot.highlight(color: LorenzColor) {
highlight(color.toColor())
}
@@ -115,6 +119,23 @@ object RenderUtils {
GlStateManager.enableCull()
}
+ val absoluteTranslation
+ get() = run {
+ matrixBuffer.clear()
+
+ GlStateManager.getFloat(GL11.GL_MODELVIEW_MATRIX, matrixBuffer)
+
+ val read = generateSequence(0) { it + 1 }.take(16).map { matrixBuffer.get() }.toList()
+
+ val xTranslate = read[12].toInt()
+ val yTranslate = read[13].toInt()
+ val zTranslate = read[14].toInt()
+
+ matrixBuffer.flip()
+
+ Triple(xTranslate, yTranslate, zTranslate)
+ }
+
fun getViewerPos(partialTicks: Float) = exactLocation(Minecraft.getMinecraft().renderViewEntity, partialTicks)
fun AxisAlignedBB.expandBlock() = expand(0.0020000000949949026, 0.0020000000949949026, 0.0020000000949949026)