added getWidth() method to GuiString which returns the width of the drawn String (calculated using FontRenderer#getStringWidth())

This commit is contained in:
CrushedPixel
2015-07-19 02:34:10 +02:00
parent 3c7c1198cc
commit b851632ffb

View File

@@ -78,4 +78,13 @@ public class GuiString extends Gui implements GuiElement {
public void setElementEnabled(boolean enabled) { public void setElementEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }
public int getWidth() {
try {
return Minecraft.getMinecraft().fontRendererObj.getStringWidth(this.getContent.call());
} catch(Exception e) {
e.printStackTrace();
return 0;
}
}
} }