Skip to content

Commit

Permalink
Fix incorrect background colors on text tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Dec 10, 2023
1 parent c3b6b5e commit b42a15f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -61,7 +61,7 @@ public void render(PoseStack poseStack, MultiBufferSource buffer, int light, int
// prepare variables
Font font = Minecraft.getInstance().font;
int l = this.customization.light != null ? this.customization.light : light;
int bg = backgroundColor != null ? backgroundColor : background ? (int) (Minecraft.getInstance().options.getBackgroundOpacity(0.25f) * 0xFF) << 24 : 0;
int bg = backgroundColor != null ? ColorUtils.intRGBAToIntARGB(backgroundColor) : background ? (int) (Minecraft.getInstance().options.getBackgroundOpacity(0.25f) * 0xFF) << 24 : 0;
int out = outlineColor != null ? outlineColor : 0x202020;
int op = opacity << 24 | 0xFFFFFF;
Font.DisplayMode displayMode = seeThrough ? Font.DisplayMode.SEE_THROUGH : Font.DisplayMode.POLYGON_OFFSET;
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/java/org/figuramc/figura/utils/ColorUtils.java
Expand Up @@ -207,6 +207,16 @@ public static int rgbaToIntARGB(FiguraVec4 rgba) {
return hex;
}

// This actually seems to storing BGAR this whole file is a lie, but i will just play along...
public static int intRGBAToIntARGB(int hexRGBA) {
int green = (hexRGBA >> 16) & 0xFF;
int blue = (hexRGBA >> 8) & 0xFF;
int alpha = hexRGBA & 0xFF;
int red = (hexRGBA >> 24) & 0xFF;

return ((alpha << 24) | (red << 16) | (green << 8) | blue);
}

public static int rgbaToInt(FiguraVec4 rgba) {
int hex = (int) (rgba.x * 0xFF);
hex = (hex << 8) + (int) (rgba.y * 0xFF);
Expand Down

0 comments on commit b42a15f

Please sign in to comment.