#[Solved] Text is not rendered
22 messages · Page 1 of 1 (latest)
package freedman.saomod.hud;
public class SAOHudBars {
private static final int BASE_SCREEN_WIDTH = 1920;
private static final int BASE_SCREEN_HEIGHT = 1080;
private static final int BASE_WIDTH = 600;
private static final int BASE_HEIGHT = 95;
private static float displayedHp = 0;
private static float displayedMp = 0;
private static final Identifier CUSTOM_FONT = Identifier.of("saomod", "sao_font");
public static void register() {
HudElementRegistry.attachElementBefore(VanillaHudElements.MISC_OVERLAYS,
Identifier.of("saomod", "hudbars"),
SAOHudBars::render);
}
private static void render(DrawContext context, RenderTickCounter tickDelta) {
MinecraftClient client = MinecraftClient.getInstance();
if (client == null || client.player == null || client.options.hudHidden) return;
int screenWidth = client.getWindow().getFramebufferWidth();
int screenHeight = client.getWindow().getFramebufferHeight();
float scaleX = (float) screenWidth / BASE_SCREEN_WIDTH;
float scaleY = (float) screenHeight / BASE_SCREEN_HEIGHT;
float autoScale = Math.min(scaleX, scaleY);
float scaleFix = (float) client.getWindow().getScaleFactor();
int offsetX = (int) (20 * autoScale);
int offsetY = (int) (20 * autoScale);
int nameX = 75;
int nameY = 8;
String playerName = client.player.getName().getString();
Text styledName = Text.literal(playerName).setStyle(Style.EMPTY.withFont(CUSTOM_FONT));
// context.getMatrices().scale(2.0f, 2.0f);
context.drawText(client.textRenderer, styledName, nameX, nameY, 0xFFFFFF, false);
its argb now so change 0xffffff to 0xffffffff
I mistook ARGB for RGBA, perhaps that is indeed a mistake, I did not pay attention to it.
What do the last two characters stand for?
It works, thank you.
[Solved] Text is not rendered
alpha channel
0xaarrggbb
or it may be rgba, either way you were missing the alpha originally
I think first number is alpha or opacity. 0 is 100, 5 is 50 percentes.
We'll have to play around with this.
I'm talking about the zero before x.