aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
diff options
context:
space:
mode:
authorWyvest <wyvestbusiness@gmail.com>2023-11-22 08:18:19 +0900
committerWyvest <wyvestbusiness@gmail.com>2023-11-22 08:18:19 +0900
commit8b373f577d9c6dde26357ef3fc86691f1efef9b4 (patch)
treea5328e995d8f4df21a9fe94ac8e384be08833c70 /src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
parent64230799777473246b5f98efbc596206c5bbf42d (diff)
downloadChatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.tar.gz
Chatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.tar.bz2
Chatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.zip
update PGT and relocate to org.polyfrost
Diffstat (limited to 'src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java')
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
deleted file mode 100644
index 448ba6e..0000000
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package cc.woverflow.chatting.mixin;
-
-import cc.polyfrost.oneconfig.gui.animations.EaseOutQuad;
-import cc.polyfrost.oneconfig.utils.MathUtils;
-import cc.woverflow.chatting.Chatting;
-import cc.woverflow.chatting.chat.ChatScrollingHook;
-import cc.woverflow.chatting.config.ChattingConfig;
-import net.minecraft.client.gui.ChatLine;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiNewChat;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.Unique;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-import java.util.List;
-
-@Mixin(GuiNewChat.class)
-public abstract class GuiNewChatMixin_Scrolling extends Gui {
- @Shadow private int scrollPos;
- @Shadow @Final private List<ChatLine> drawnChatLines;
-
- @Shadow public abstract int getLineCount();
-
- @Shadow private boolean isScrolled;
-
- @Unique
- private EaseOutQuad chatting$scrollingAnimation;
-
- @Inject(method = "drawChat", at = @At("HEAD"))
- private void chatting$scrollingAnimationStart(int updateCounter, CallbackInfo ci) {
- if (chatting$scrollingAnimation != null) {
- if (chatting$scrollingAnimation.isFinished()) {
- if (scrollPos == 0) {
- isScrolled = false;
- }
- chatting$scrollingAnimation = null;
- } else {
- scrollPos = (int) chatting$scrollingAnimation.get(Chatting.INSTANCE.getDeltaTime());
- }
- }
- }
-
- @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 1))
- private void redirectScrollBar(int left, int top, int right, int bottom, int color) {
- if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
- drawRect(left, top, right, bottom, color);
- }
- }
-
- @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 2))
- private void redirectScrollBar2(int left, int top, int right, int bottom, int color) {
- if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
- drawRect(left, top, right, bottom, color);
- }
- }
-
- @Inject(method = "scroll", at = @At("HEAD"), cancellable = true)
- private void injectScroll(int amount, CallbackInfo ci) {
- if (ChattingConfig.INSTANCE.getSmoothScrolling() && amount != 0 && ChatScrollingHook.INSTANCE.getShouldSmooth()) {
- ci.cancel();
- ChatScrollingHook.INSTANCE.setShouldSmooth(false);
- int result = (int) MathUtils.clamp(scrollPos + amount, 0, Math.max(drawnChatLines.size() - getLineCount() - 1, 0));
- chatting$scrollingAnimation = new EaseOutQuad((int) (ChattingConfig.INSTANCE.getScrollingSpeed() * 1000), scrollPos, result, false);
- }
- }
-}