From c9b5b020ecbbc48cdbb7580c60125589a2529604 Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Sat, 5 Nov 2022 20:23:46 +0100 Subject: Chat peeking (#6) --- .../at/hannibal2/skyhanni/config/features/Chat.java | 6 ++++++ .../mixins/transformers/gui/MixinGuiNewChat.java | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java index d00813c2b..e12d96f57 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java @@ -2,9 +2,15 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.core.config.annotations.*; import com.google.gson.annotations.Expose; +import org.lwjgl.input.Keyboard; public class Chat { + @Expose + @ConfigOption(name = "Peek Chat", desc = "Hold this key to keep the chat open") + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_Z) + public int peekChat = Keyboard.KEY_Z; + @Expose @ConfigOption(name = "Chat Filter Types", desc = "") @ConfigEditorAccordion(id = 0) diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java new file mode 100644 index 000000000..f21b4c948 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.mixins.transformers.gui; + +import at.hannibal2.skyhanni.SkyHanniMod; +import net.minecraft.client.gui.GuiNewChat; +import org.lwjgl.input.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(GuiNewChat.class) +public class MixinGuiNewChat { + + @Inject(method = "getChatOpen", at = @At("HEAD"), cancellable = true) + public void onIsOpen(CallbackInfoReturnable cir) { + if (SkyHanniMod.feature.chat.peekChat != Keyboard.KEY_NONE && Keyboard.isKeyDown(SkyHanniMod.feature.chat.peekChat)) + cir.setReturnValue(true); + } + +} -- cgit