From e036fd14a833fc61d60ec330f21ae7ad77f732ff Mon Sep 17 00:00:00 2001 From: slprime <31038811+slprime@users.noreply.github.com> Date: Tue, 13 Jan 2026 15:16:09 +0200 Subject: [PATCH] Correctly crop colored text (#839) --- src/main/java/codechicken/nei/NEIClientUtils.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/codechicken/nei/NEIClientUtils.java b/src/main/java/codechicken/nei/NEIClientUtils.java index b11a5c14..023094fa 100644 --- a/src/main/java/codechicken/nei/NEIClientUtils.java +++ b/src/main/java/codechicken/nei/NEIClientUtils.java @@ -413,18 +413,11 @@ public class NEIClientUtils extends NEIServerUtils { if (textWidth > containerWidth) { int dots = fontRenderer.getStringWidth("..."); - if (containerWidth > dots) { - textWidth += dots; - - while (textWidth > containerWidth) { - textWidth -= fontRenderer.getCharWidth(text.charAt(text.length() - 1)); - text = text.substring(0, text.length() - 1); - } - - return text + "..."; + if (containerWidth <= dots) { + return "..."; } - return "..."; + return fontRenderer.trimStringToWidth(text, containerWidth - dots) + "..."; } return text;