Added TooltipRenderer to mimic Item Tooltip Rendering for hover texts and replaced some error/info messages to use the TooltipRenderer

This commit is contained in:
CrushedPixel
2015-05-31 17:13:13 +02:00
parent dec1cf398c
commit 39fe6dec4e
9 changed files with 133 additions and 47 deletions

View File

@@ -0,0 +1,36 @@
package eu.crushedpixel.replaymod.utils;
import net.minecraft.client.Minecraft;
import java.util.ArrayList;
import java.util.List;
public class StringUtils {
private static final Minecraft mc = Minecraft.getMinecraft();
public static String[] splitStringInMultipleRows(String string, int maxWidth) {
List<String> rows = new ArrayList<String>();
String remaining = string;
while(remaining.length() > 0) {
String[] split = remaining.split(" ");
String b = "";
for(String sp : split) {
b += sp + " ";
if(mc.fontRendererObj.getStringWidth(b.trim()) > maxWidth) {
b = b.substring(0, b.trim().length() - (sp.length()));
break;
}
}
String trimmed = b.trim();
rows.add(trimmed);
try {
remaining = remaining.substring(trimmed.length() + 1);
} catch(Exception e) {
break;
}
}
return rows.toArray(new String[rows.size()]);
}
}