diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-03-26 12:47:57 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-03-26 12:47:57 +0700 |
commit | c68035e02240469f94905ae8edccf9222e027485 (patch) | |
tree | e7340611943dbed345de3388ddc9c5745a5f8c2d /src | |
parent | 56ffd09c8018d8a1f740cd020d970393cc2abfda (diff) | |
download | Chatting-c68035e02240469f94905ae8edccf9222e027485.tar.gz Chatting-c68035e02240469f94905ae8edccf9222e027485.tar.bz2 Chatting-c68035e02240469f94905ae8edccf9222e027485.zip |
fix alpha of chat background
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java | 12 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt | 6 | ||||
-rw-r--r-- | src/main/resources/mixins.chatting.json | 4 |
3 files changed, 15 insertions, 7 deletions
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)) diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt index 223de76..4684e22 100644 --- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt +++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt @@ -48,7 +48,8 @@ object ChattingConfig : type = PropertyType.COLOR, name = "Chat Background Color", description = "Change the color of the chat background.", - category = "General" + category = "General", + allowAlpha = false ) var chatBackgroundColor = Color(0, 0, 0, 128) @@ -56,7 +57,8 @@ object ChattingConfig : type = PropertyType.COLOR, name = "Copy Chat Message Background Color", description = "Change the color of chat messages that are ready to copy.", - category = "General" + category = "General", + allowAlpha = false ) var hoveredChatBackgroundColor = Color(80, 80, 80, 128) diff --git a/src/main/resources/mixins.chatting.json b/src/main/resources/mixins.chatting.json index 814bf92..35e4024 100644 --- a/src/main/resources/mixins.chatting.json +++ b/src/main/resources/mixins.chatting.json @@ -10,9 +10,7 @@ "GuiNewChatAccessor", "GuiNewChatMapMixin", "GuiNewChatMixin", - "GuiUtilsMixin", - "RedactionNameHighlightMixin", - "WyvtilsListenerMixin" + "GuiUtilsMixin" ], "verbose": true }
\ No newline at end of file |