fix invisible text for colors without an alpha channel
FrosFont.flush passed colors to AWT as RGBA, so vanilla-style rgb constants like 0x55FF55 got alpha 0 and drew fully transparent - this made the Armor HUD's durability percentages (green/yellow/red) never show. Alpha-less colors now draw opaque, matching vanilla's own treatment of ChatFormatting-style colors.
This commit is contained in:
@@ -414,7 +414,11 @@ public final class FrosFont {
|
||||
private static int flush(Graphics2D graphics, String text, int start, int end, int cursor, int color, int baseline) {
|
||||
if (end <= start) return cursor;
|
||||
String segment = text.substring(start, end);
|
||||
graphics.setColor(new Color(color, true));
|
||||
// rgb colors without an alpha channel (0x55FF55, like vanilla's own
|
||||
// formatting codes) draw opaque, matching vanilla's rule of treating
|
||||
// a missing alpha as 255 instead of rendering invisible text
|
||||
int argb = (color & 0xFF000000) == 0 ? 0xFF000000 | color : color;
|
||||
graphics.setColor(new Color(argb, true));
|
||||
graphics.drawString(segment, cursor, baseline);
|
||||
return cursor + metrics.stringWidth(segment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user