aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <nea@nea.moe>2023-03-31 21:32:42 +0200
committerGitHub <noreply@github.com>2023-03-31 21:32:42 +0200
commit53c1440fa4a42613b140f4f099b60c3664ba0fdd (patch)
tree0341c3b48d533fdc3f2efa9e172cd4f6c37eeb14 /src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
parente6bcc8f902e410c348ff720ab73de14e5cf04280 (diff)
downloadskyhanni-53c1440fa4a42613b140f4f099b60c3664ba0fdd.tar.gz
skyhanni-53c1440fa4a42613b140f4f099b60c3664ba0fdd.tar.bz2
skyhanni-53c1440fa4a42613b140f4f099b60c3664ba0fdd.zip
Add rancher boot overlay for optimal crop speeds (#25)
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.kt29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 491b73d31..df5567415 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.GuiEditManager
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
-import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen
+import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.moulconfig.internal.TextRenderUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer
@@ -14,7 +14,6 @@ import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.entity.Entity
import net.minecraft.inventory.Slot
-import net.minecraft.item.ItemStack
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.MathHelper
import net.minecraft.util.ResourceLocation
@@ -517,27 +516,17 @@ object RenderUtils {
}
private fun Position.renderLine(line: List<Any?>, offsetY: Int, itemScale: Double = 1.0): Int {
- val renderer = Minecraft.getMinecraft().fontRendererObj
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(getAbsX().toFloat(), (getAbsY() + offsetY).toFloat(), 0F)
var offsetX = 0
for (any in line) {
- if (any == null) {
- offsetX += 12
- continue
- }
- if (any is String) {
- renderString0(any, offsetX, offsetY)
- val width = renderer.getStringWidth(any)
- offsetX += width
- } else if (any is ItemStack) {
- val isX = getAbsX() + offsetX
- val isY = getAbsY() + offsetY
-
- any.renderOnScreen(isX.toFloat(), isY.toFloat(), itemScale)
- offsetX += 12
- } else {
- throw RuntimeException("Unknown render object: $any")
- }
+ val renderable = Renderable.fromAny(any, itemScale = itemScale) ?: throw RuntimeException("Unknown render object: ${any}")
+
+ renderable.render(getAbsX() + offsetX, getAbsY() + offsetY)
+ offsetX += renderable.width
+ GlStateManager.translate(renderable.width.toFloat(), 0F, 0F)
}
+ GlStateManager.popMatrix()
return offsetX
}