aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-17 09:44:34 -0500
committerWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-17 09:44:34 -0500
commit5822703b7d770ec67a4c4ca00192006b8f0cb9b9 (patch)
tree7ded70762db28ec2321ce25bd20d3313a26c52df /src/main/java
parent6120b123648f2ccf7a5d5efea1a5c3600a725196 (diff)
downloadChatting-5822703b7d770ec67a4c4ca00192006b8f0cb9b9.tar.gz
Chatting-5822703b7d770ec67a4c4ca00192006b8f0cb9b9.tar.bz2
Chatting-5822703b7d770ec67a4c4ca00192006b8f0cb9b9.zip
smooth messages / scrolling animation speed
fix sending messages (again lol)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java5
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java3
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java36
3 files changed, 24 insertions, 20 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
index b253fe1..fa125cb 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
@@ -24,11 +24,16 @@ public class EntityPlayerSPMixin {
return;
}
if (ChattingConfig.INSTANCE.getChatTabs() && !ChatTabs.INSTANCE.getCurrentTabs().isEmpty()) {
+ boolean sent = false;
for (ChatTab tab : ChatTabs.INSTANCE.getCurrentTabs()) {
if (tab.getPrefix() != null && !tab.getPrefix().isEmpty()) {
sendQueue.addToSendQueue(new C01PacketChatMessage(tab.getPrefix() + value));
+ sent = true;
}
}
+ if (!sent) {
+ sendQueue.addToSendQueue(packet);
+ }
} else {
sendQueue.addToSendQueue(packet);
}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
index 8598a94..c87ec6f 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java
@@ -43,7 +43,6 @@ public abstract class GuiNewChatMixin_Scrolling extends Gui {
scrollPos = (int) chatting$scrollingAnimation.get(Chatting.INSTANCE.getDeltaTicks());
}
}
- Chatting.INSTANCE.setDeltaTicks(0);
}
@Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 1))
@@ -66,7 +65,7 @@ public abstract class GuiNewChatMixin_Scrolling extends Gui {
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(150, scrollPos, result, false);
+ chatting$scrollingAnimation = new EaseOutQuad((int) (ChattingConfig.INSTANCE.getScrollingSpeed() * 1000), scrollPos, result, false);
}
}
}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
index 65140aa..ee94a35 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
@@ -1,9 +1,10 @@
package cc.woverflow.chatting.mixin;
-import cc.polyfrost.oneconfig.utils.MathUtils;
+import cc.woverflow.chatting.Chatting;
import cc.woverflow.chatting.chat.ChatSearchingManager;
import cc.woverflow.chatting.chat.ChatTabs;
import cc.woverflow.chatting.config.ChattingConfig;
+import cc.woverflow.chatting.utils.EaseOutQuart;
import net.minecraft.client.gui.GuiNewChat;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.EnumChatFormatting;
@@ -20,6 +21,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
import java.util.Locale;
+/**
+ * Taken from BetterChat under LGPL 3.0
+ * <a href="https://github.com/LlamaLad7/Better-Chat/blob/1.8.9/LICENSE">https://github.com/LlamaLad7/Better-Chat/blob/1.8.9/LICENSE</a>
+ */
@Mixin(GuiNewChat.class)
public abstract class GuiNewChatMixin_SmoothMessages {
@Shadow
@@ -27,30 +32,25 @@ public abstract class GuiNewChatMixin_SmoothMessages {
@Shadow
public abstract float getChatScale();
-
- private float chatting$percentComplete; //be nice and allow other mods to access this :)
@Unique
private int chatting$newLines;
- @Unique
- private long chatting$prevMillis = System.currentTimeMillis();
- @Unique
+
+ private EaseOutQuart chatting$easeOutQuart;
private float chatting$animationPercent;
@Unique
private int chatting$lineBeingDrawn;
- private void updatePercentage(long diff) {
- if (chatting$percentComplete < 1) chatting$percentComplete += 0.004f * diff;
- chatting$percentComplete = MathUtils.clamp(chatting$percentComplete, 0, 1);
- }
-
@Inject(method = "drawChat", at = @At("HEAD"))
private void modifyChatRendering(CallbackInfo ci) {
- long current = System.currentTimeMillis();
- long diff = current - chatting$prevMillis;
- chatting$prevMillis = current;
- updatePercentage(diff);
- float t = chatting$percentComplete;
- chatting$animationPercent = MathUtils.clamp(1 - (--t) * t * t * t, 0, 1);
+ if (chatting$easeOutQuart != null) {
+ if (chatting$easeOutQuart.isFinished()) {
+ chatting$easeOutQuart = null;
+ } else {
+ chatting$animationPercent = chatting$easeOutQuart.get(Chatting.INSTANCE.getDeltaTicks());
+ }
+ } else {
+ chatting$animationPercent = 1;
+ }
}
@Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;pushMatrix()V", ordinal = 0, shift = At.Shift.AFTER))
@@ -88,7 +88,7 @@ public abstract class GuiNewChatMixin_SmoothMessages {
ChatTabs.INSTANCE.setHasCancelledAnimation(false);
return;
}
- chatting$percentComplete = 0;
+ chatting$easeOutQuart = new EaseOutQuart(ChattingConfig.INSTANCE.getMessageSpeed() * 1000f, 0f, 1f, false);
}
@ModifyVariable(method = "setChatLine", at = @At("STORE"), ordinal = 0)