aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/mixins/hooks
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2024-04-25 08:43:01 +0100
committerGitHub <noreply@github.com>2024-04-25 09:43:01 +0200
commitf3b3b44296b8a6ac77ecad433ca28e7a03a9eaf2 (patch)
tree4a1e45727434c16489c748fad7eefe4117be5875 /src/main/java/at/hannibal2/skyhanni/mixins/hooks
parented53f750e6b68067f58a5e706db220760d57029f (diff)
downloadskyhanni-f3b3b44296b8a6ac77ecad433ca28e7a03a9eaf2.tar.gz
skyhanni-f3b3b44296b8a6ac77ecad433ca28e7a03a9eaf2.tar.bz2
skyhanni-f3b3b44296b8a6ac77ecad433ca28e7a03a9eaf2.zip
Feature: SBA style Enchant Parsing (#654)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiChatHook.kt40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiChatHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiChatHook.kt
new file mode 100644
index 000000000..354707f85
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiChatHook.kt
@@ -0,0 +1,40 @@
+package at.hannibal2.skyhanni.mixins.hooks
+
+import net.minecraft.event.HoverEvent
+import net.minecraft.util.ChatComponentText
+import net.minecraft.util.ChatStyle
+import net.minecraft.util.IChatComponent
+
+object GuiChatHook {
+
+ lateinit var replacement: ChatComponentText
+
+ fun replaceEntireComponent(title: String, chatStyle: ChatStyle) {
+ if (!this::replacement.isInitialized) return
+
+ // Initialise new component
+ val newComponent = ChatComponentText(title)
+ newComponent.setChatStyle(chatStyle)
+
+ replacement = newComponent
+ }
+
+ fun replaceOnlyHoverEvent(hoverEvent: HoverEvent) {
+ if (!this::replacement.isInitialized) return
+
+ // Initialise new component
+ val newComponent = ChatComponentText(replacement.chatComponentText_TextValue)
+ newComponent.setChatStyle(replacement.chatStyle)
+ newComponent.chatStyle.chatHoverEvent = hoverEvent
+
+ replacement = newComponent
+ }
+
+ fun getReplacementAsIChatComponent(): IChatComponent {
+ if (!this::replacement.isInitialized) {
+ // Return an extremely basic chat component as to not error downstream
+ return ChatComponentText("Original component was not set")
+ }
+ return replacement
+ }
+}