From e66f45ac7ea014bcf579b7a3d56033d082ebb763 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:07:59 +0100 Subject: Improvement: HoverTips improvements (#821) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt') 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) -- cgit