aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ChatPeekScrollPatch.java27
-rw-r--r--src/main/kotlin/features/fixes/Fixes.kt5
2 files changed, 32 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
+ }
}