From c68035e02240469f94905ae8edccf9222e027485 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sat, 26 Mar 2022 12:47:57 +0700 Subject: fix alpha of chat background --- .../java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java') diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java index d6a0b15..e9acce1 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java @@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; +import java.awt.*; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.awt.image.BufferedImage; @@ -106,11 +107,18 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook { if (mouseX >= (left + ModCompatHooks.getXOffset()) && mouseY < bottom && mouseX < (right + 11 + ModCompatHooks.getXOffset()) && mouseY >= top) { chatting$shouldCopy = true; drawCopyChatBox(right, top); - args.set(4, ChattingConfig.INSTANCE.getHoveredChatBackgroundColor().getRGB()); + args.set(4, changeChatBackgroundColor(ChattingConfig.INSTANCE.getHoveredChatBackgroundColor(), args.get(4))); return; } } - args.set(4, ChattingConfig.INSTANCE.getChatBackgroundColor().getRGB()); + args.set(4, changeChatBackgroundColor(ChattingConfig.INSTANCE.getChatBackgroundColor(), args.get(4))); + } + + private int changeChatBackgroundColor(Color color, int alphaColor) { + return (((alphaColor >> 24) & 0xFF) << 24) | + ((color.getRed() & 0xFF) << 16) | + ((color.getGreen() & 0xFF) << 8) | + ((color.getBlue() & 0xFF)); } @Redirect(method = "drawChat", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/GuiNewChat;drawnChatLines:Ljava/util/List;", opcode = Opcodes.GETFIELD)) -- cgit