diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-01-09 00:15:10 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-01-09 00:15:10 +0700 |
commit | ddc94dc9388086657b889d8fd43a82bcadd82bbe (patch) | |
tree | a407b76c62122298e43ff51b10a78114637d5bba | |
parent | 7612c2e65d07e9b3ce13729da4eb95a6d7173a71 (diff) | |
download | Chatting-ddc94dc9388086657b889d8fd43a82bcadd82bbe.tar.gz Chatting-ddc94dc9388086657b889d8fd43a82bcadd82bbe.tar.bz2 Chatting-ddc94dc9388086657b889d8fd43a82bcadd82bbe.zip |
fix chat copy being in the wrong position
5 files changed, 15 insertions, 20 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java index 73b76e7..b39950b 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java @@ -83,7 +83,7 @@ public abstract class GuiChatMixin extends GuiScreen { GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI()); float f = mc.ingameGUI.getChatGUI().getChatScale(); int x = MathHelper.floor_float((float) mouseX / f); - if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset()) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 11 > x) { + if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) { GuiUtils.drawHoveringText(COPY_TOOLTIP, mouseX, mouseY, width, height, -1, fontRendererObj); GlStateManager.disableLighting(); } @@ -94,7 +94,7 @@ public abstract class GuiChatMixin extends GuiScreen { GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI()); float f = mc.ingameGUI.getChatGUI().getChatScale(); int x = MathHelper.floor_float((float) mouseX / f); - if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset()) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 11 > x) { + if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) { Transferable message = hook.getChattingChatComponent(Mouse.getY()); if (message == null) return; try { diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java index 4edafb2..677ba4c 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java @@ -181,8 +181,8 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook { GlStateManager.blendFunc(770, 771); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); chatting$right = right; - Gui.drawModalRectWithCustomSizedTexture(right, top, 0f, 0f, 9, 9, 9, 9); - drawRect(right - 1, top - 1, right + 10, top + 10, (((right + ModCompatHooks.getXOffset()) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 11 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor())); + Gui.drawModalRectWithCustomSizedTexture(right + 1, top, 0f, 0f, 9, 9, 9, 9); + drawRect(right + 1, top, right + 11, top + 9, (((right + ModCompatHooks.getXOffset() + 3) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 13 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor())); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt index f72967f..5cbbc2d 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt @@ -1,7 +1,6 @@ package cc.woverflow.chatting.chat import cc.woverflow.chatting.Chatting -import cc.woverflow.chatting.utils.ListenableArrayList import com.google.gson.JsonObject import com.google.gson.JsonParser import java.io.File @@ -12,11 +11,16 @@ object ChatShortcuts { private var initialized = false - val shortcuts = ListenableArrayList<Pair<String, String>>({ - it.sortWith(comparator) - }) - private val comparator = Comparator<Pair<String, String>> { o1, o2 -> - return@Comparator o2.first.length.compareTo(o1.first.length) + val shortcuts = object : ArrayList<Pair<String, String>>() { + private val comparator = Comparator<Pair<String, String>> { o1, o2 -> + return@Comparator o2.first.length.compareTo(o1.first.length) + } + + override fun add(element: Pair<String, String>): Boolean { + val value = super.add(element) + sortWith(comparator) + return value + } } diff --git a/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt b/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt index ef1e376..dadaf0c 100644 --- a/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt +++ b/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt @@ -27,7 +27,7 @@ object Updater { DefaultArtifactVersion(Chatting.VER.substringBefore("-")) val latestVersion = DefaultArtifactVersion(latestTag!!.substringAfter("v").substringBefore("-")) if (currentVersion >= latestVersion) { - if (currentVersion != latestVersion || !Chatting.VER.contains("-")) { + if (currentVersion.compareTo(latestVersion) == 0 || !Chatting.VER.contains("-")) { return@runAsync } } diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt b/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt deleted file mode 100644 index 0cd598c..0000000 --- a/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt +++ /dev/null @@ -1,9 +0,0 @@ -package cc.woverflow.chatting.utils - -class ListenableArrayList<T>(private val runnable: (ListenableArrayList<T>) -> Unit, vararg elements: T): ArrayList<T>() { - override fun add(element: T): Boolean { - val value = super.add(element) - runnable.invoke(this) - return value - } -}
\ No newline at end of file |