diff options
| author | Natalia Spence <52349324+Septikai@users.noreply.github.com> | 2025-11-17 18:49:14 +0000 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-17 23:10:28 +0100 |
| commit | 54206c51148255320ad8bc8d03c122d24b98b459 (patch) | |
| tree | c6f658806cf6bb08fe88390af53f4bca0ec48407 | |
| parent | c7669dc363716c63f987c29809997b2787349370 (diff) | |
| download | Firmament-54206c51148255320ad8bc8d03c122d24b98b459.tar.gz Firmament-54206c51148255320ad8bc8d03c122d24b98b459.tar.bz2 Firmament-54206c51148255320ad8bc8d03c122d24b98b459.zip | |
feat: add option to allow scrolling on chat peek
Co-Authored-By: Linnea Gräf <nea@nea.moe>
(cherry picked from commit 73ff3648c3fc52b817456bfad3ff0380a55cdc43)
| -rw-r--r-- | src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java | 27 | ||||
| -rw-r--r-- | src/main/kotlin/features/fixes/Fixes.kt | 5 | ||||
| -rw-r--r-- | translations/en_us.json | 2 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java b/src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java new file mode 100644 index 0000000..c795908 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java @@ -0,0 +1,27 @@ +package moe.nea.firmament.mixins; + +import moe.nea.firmament.features.fixes.Fixes; +import net.minecraft.client.Minecraft; +import net.minecraft.client.MouseHandler; +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.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MouseHandler.class) +public class ChatPeekScrollPatch { + + @Inject(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;getSelectedSlot()I"), cancellable = true) + public void onHotbarScrollWhilePeeking(long window, double horizontal, double vertical, CallbackInfo ci) { + if (Fixes.INSTANCE.shouldPeekChat() && Fixes.INSTANCE.shouldScrollPeekedChat()) ci.cancel(); + } + + @ModifyVariable(method = "onScroll", at = @At(value = "STORE"), ordinal = 0) + public int onGetChatHud(int i) { + if (Fixes.INSTANCE.shouldPeekChat() && Fixes.INSTANCE.shouldScrollPeekedChat()) + Minecraft.getInstance().gui.getChat().scrollChat(i); + return i; + } + +} diff --git a/src/main/kotlin/features/fixes/Fixes.kt b/src/main/kotlin/features/fixes/Fixes.kt index 161c7e5..bb17536 100644 --- a/src/main/kotlin/features/fixes/Fixes.kt +++ b/src/main/kotlin/features/fixes/Fixes.kt @@ -25,6 +25,7 @@ object Fixes { val autoSprintUnderWater by toggle("auto-sprint-underwater") { true } val autoSprintHud by position("auto-sprint-hud", 80, 10) { Vector2i() } val peekChat by keyBindingWithDefaultUnbound("peek-chat") + val peekChatScroll by toggle("peek-chat-scroll") { false } val hidePotionEffects by toggle("hide-mob-effects") { false } val hidePotionEffectsHud by toggle("hide-potion-effects-hud") { false } val noHurtCam by toggle("disable-hurt-cam") { false } @@ -77,4 +78,8 @@ object Fixes { fun shouldPeekChat(): Boolean { return TConfig.peekChat.isPressed(atLeast = true) } + + fun shouldScrollPeekedChat(): Boolean { + return TConfig.peekChatScroll + } } diff --git a/translations/en_us.json b/translations/en_us.json index fbe530a..0700339 100644 --- a/translations/en_us.json +++ b/translations/en_us.json @@ -182,6 +182,8 @@ "firmament.config.fixes.hide-slot-highlights": "Hide Slot Highlights", "firmament.config.fixes.hide-slot-highlights.description": "Hide slot highlights for items with disabled tooltip. This makes /sbmenu look nicer with smooth texture packs.", "firmament.config.fixes.peek-chat": "Peek Chat", + "firmament.config.fixes.peek-chat-scroll": "Scroll Peeked Chat", + "firmament.config.fixes.peek-chat-scroll.description": "Allow scrolling chat while peeking.", "firmament.config.fixes.peek-chat.description": "Hold this keybinding to view the chat as if you have it opened, but while still being able to control your character.", "firmament.config.fixes.player-skins": "Fix unsigned Player Skins", "firmament.config.fixes.player-skins.description": "Mark all player skins as signed, preventing console spam, and some rendering issues.", |
