From 54206c51148255320ad8bc8d03c122d24b98b459 Mon Sep 17 00:00:00 2001 From: Natalia Spence <52349324+Septikai@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:49:14 +0000 Subject: feat: add option to allow scrolling on chat peek MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Linnea Gräf (cherry picked from commit 73ff3648c3fc52b817456bfad3ff0380a55cdc43) --- .../nea/firmament/mixins/ChatPeekScrollPatch.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java (limited to 'src/main/java') 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; + } + +} -- cgit