package ftbsc.bscv.tools; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import ftbsc.bscv.ICommons; import net.minecraft.client.MainWindow; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.math.vector.Vector2f; import net.minecraft.util.text.Color; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.Style; public final class Text implements ICommons { String text; Anchor anchor; Style style; int x; int y; double scale; private Text() { this.text = ""; this.anchor = Anchor.TOPLEFT; this.style = Style.EMPTY.withColor(Color.fromRgb(16777215)); this.x = 0; this.y = 0; this.scale = 1.0; } public static Text TextBuilder() { return new Text(); } public Text txt(String txt, Object... arg) { this.text = String.format(txt, arg); return this; } public Text anchor(Anchor a) { this.anchor = a; return this; } public Text style(Style in) { this.style = in; return this; } public Text x(int x) { this.x = x; return this; } public Text y(int y) { this.y = y; return this; } public Text scale(double scale) { this.scale = scale; return this; } public void render(MatrixStack stack, MainWindow window) { FontRenderer font = MC.font; ITextComponent text = new StringTextComponent(this.text).setStyle(this.style); Vector2f abs_coords = this.anchor.translate( new Vector2f(this.x, this.y), font.width(text), font.lineHeight, (float) this.scale, window ); // TODO is there any non-deprecated way? RenderSystem.pushMatrix(); RenderSystem.scaled(this.scale, this.scale, this.scale); font.drawShadow( stack, text, abs_coords.x, abs_coords.y, 10 // ???? TODO! ); RenderSystem.popMatrix(); } }