diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-03-21 21:07:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 21:07:59 +0100 |
commit | e66f45ac7ea014bcf579b7a3d56033d082ebb763 (patch) | |
tree | 703722ab1f9394936b796386c3950c1b0e0d40be /src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | |
parent | 505b963af2b27e6f5a2783f27c20ff209628b60b (diff) | |
download | skyhanni-e66f45ac7ea014bcf579b7a3d56033d082ebb763.tar.gz skyhanni-e66f45ac7ea014bcf579b7a3d56033d082ebb763.tar.bz2 skyhanni-e66f45ac7ea014bcf579b7a3d56033d082ebb763.zip |
Improvement: HoverTips improvements (#821)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 21 |
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) |