diff options
author | inglettronald <inglettronald@gmail.com> | 2023-07-22 22:07:46 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-07-22 22:07:46 -0500 |
commit | 4e8e3ae91f8be1906c298bf7b0aceb1b39d083d3 (patch) | |
tree | 435f9ad0f0319a28f1e5e2a9bc3a5ec188c0cb57 /src/main/kotlin/com/dulkirfabric/util | |
parent | e3f9d34e8ad5ff1effcba2cc39c7f375edaab115 (diff) | |
download | DulkirMod-Fabric-4e8e3ae91f8be1906c298bf7b0aceb1b39d083d3.tar.gz DulkirMod-Fabric-4e8e3ae91f8be1906c298bf7b0aceb1b39d083d3.tar.bz2 DulkirMod-Fabric-4e8e3ae91f8be1906c298bf7b0aceb1b39d083d3.zip |
wip
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt b/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt new file mode 100644 index 0000000..40840d9 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt @@ -0,0 +1,21 @@ +package com.dulkirfabric.util + +import com.dulkirfabric.DulkirModFabric.mc +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext +import net.minecraft.client.font.TextRenderer +import net.minecraft.client.gui.DrawContext +import net.minecraft.text.Text + +object HudRenderUtil { + fun drawTitle(context: DrawContext, content: Text) { + val matrices = context.matrices + val tr = mc.textRenderer + val w = tr.getWidth(content) + val sf: Float = mc.window.scaledWidth / w.toFloat() + matrices.push() + matrices.translate(mc.currentScreen!!.width / 3f, mc.window.scaledHeight / 2f, + 0f) + matrices.scale(sf, sf, 1f) + context.drawText(tr, content, 0, -tr.fontHeight / 2, -1, true) + } +}
\ No newline at end of file |