Textdata containing only \n will cause a linebreak

This commit is contained in:
Bernhard Bonigl committed 2016-04-25 15:25:49 +02:00
1 parent 5e537bd3ee
commit 6a0429ec54
2 files changed
+8 -1

No files matched your search

@@ -7,6 +7,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class TextData {
public static final TextData LINEBREAK = new TextData("\n");
public String text;
public String color = "black";
public boolean bold = false;
@@ -34,6 +34,11 @@ public class TextDataRenderer {
if(item.text == null || item.text.isEmpty()) {
continue;
}
if(item.text.equals("\n")) {
atX = x;
atY += fr.FONT_HEIGHT;
continue;
}
if(item.paragraph) {
atX = x;
@@ -180,7 +185,7 @@ public class TextDataRenderer {
for(int i = 0; i < s.length(); i++) {
curWidth += fr.getStringWidth(modifiers + Character.toString(s.charAt(i))) * scale;
if((curHeight == (int) (fr.FONT_HEIGHT * scale) && curWidth > firstWidth) || (curHeight != (int) (fr.FONT_HEIGHT * scale) && curWidth > width)) {
if(s.charAt(i) == '\n' || (curHeight == (int) (fr.FONT_HEIGHT * scale) && curWidth > firstWidth) || (curHeight != (int) (fr.FONT_HEIGHT * scale) && curWidth > width)) {
int oldI = i;
while(i >= 0 && s.charAt(i) != ' ') {
i--;