1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package me.Danker.handlers;
import org.lwjgl.opengl.GL11;
import me.Danker.commands.ToggleCommand;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.StringUtils;
public class TextRenderer extends Gui {
public TextRenderer(Minecraft mc, String text, int x, int y, double scale) {
double scaleReset = (double) Math.pow(scale, -1);
GL11.glScaled(scale, scale, scale);
y -= mc.fontRendererObj.FONT_HEIGHT;
for (String line : text.split("\n")) {
y += mc.fontRendererObj.FONT_HEIGHT * scale;
if (ToggleCommand.outlineTextToggled) {
String noColorLine = StringUtils.stripControlCodes(line);
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) - 1, (int) Math.round(y / scale), 0x000000, false);
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) + 1, (int) Math.round(y / scale), 0x000000, false);
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) - 1, 0x000000, false);
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) + 1, 0x000000, false);
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, false);
} else {
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true);
}
}
GL11.glScaled(scaleReset, scaleReset, scaleReset);
}
}
|