From 50b689c7fec6de695ca41b8d0b9776b3c0a1af5d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:58:24 +0100 Subject: Fixed crash while rendering items. --- src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 6d99f23a1..24c7e9e1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -471,22 +471,27 @@ object RenderUtils { * Accepts a list of lines to print. * Each line is a list of things to print. Can print String or ItemStack objects. */ - fun Position.renderStringsAndItems(list: List>, extraSpace: Int = 0) { + fun Position.renderStringsAndItems(list: List>, extraSpace: Int = 0) { if (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown) return if (list.isEmpty()) return var offsetY = 0 + // TODO remove toMutableList for (line in list.toMutableList()) { renderLine(line, offsetY) offsetY += 10 + extraSpace + 2 } } - private fun Position.renderLine(line: List, offsetY: Int) { + private fun Position.renderLine(line: List, offsetY: Int) { val renderer = Minecraft.getMinecraft().fontRendererObj val resolution = ScaledResolution(Minecraft.getMinecraft()) var offsetX = 0 for (any in line) { + if (any == null) { + offsetX += 12 + continue + } if (any is String) { renderString(any, offsetX, offsetY, center = false) val width = renderer.getStringWidth(any.removeColor()) -- cgit