3
3
import cc .polyfrost .oneconfig .hud .Position ;
4
4
import cc .polyfrost .oneconfig .internal .hud .HudCore ;
5
5
import net .minecraft .client .Minecraft ;
6
+ import net .minecraft .client .gui .ChatLine ;
6
7
import net .minecraft .client .gui .GuiNewChat ;
7
8
import net .minecraft .client .gui .ScaledResolution ;
8
9
import net .minecraft .util .MathHelper ;
9
10
import org .polyfrost .chatting .chat .ChatWindow ;
10
11
import org .polyfrost .chatting .config .ChattingConfig ;
12
+ import org .polyfrost .chatting .hook .ChatLineHook ;
11
13
import org .polyfrost .chatting .utils .ModCompatHooks ;
12
14
import org .spongepowered .asm .mixin .Mixin ;
13
15
import org .spongepowered .asm .mixin .Shadow ;
16
+ import org .spongepowered .asm .mixin .Unique ;
14
17
import org .spongepowered .asm .mixin .injection .*;
15
18
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
16
19
import org .spongepowered .asm .mixin .injection .invoke .arg .Args ;
@@ -20,6 +23,8 @@ public abstract class GuiNewChatMixin_Movable {
20
23
21
24
@ Shadow public abstract int getChatWidth ();
22
25
26
+ @ Unique private static ChatLine currentLine ;
27
+
23
28
@ ModifyArgs (method = "drawChat" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V" , ordinal = 0 ))
24
29
private void translate (Args args ) {
25
30
ChatWindow hud = ChattingConfig .INSTANCE .getChatWindow ();
@@ -52,7 +57,7 @@ private void exampleChat(int updateCounter, CallbackInfo ci) {
52
57
private int mouseX (int constant ) {
53
58
ChattingConfig config = ChattingConfig .INSTANCE ;
54
59
ChatWindow hud = config .getChatWindow ();
55
- return (int ) ((hud .position .getX ()) + (hud .getPaddingX () + 1 + ( config . getShowChatHeads () && config . getOffsetNonPlayerMessages () ? 8 : 0 ) ) * hud .getScale ());
60
+ return (int ) ((hud .position .getX ()) + (hud .getPaddingX () + 1 ) * hud .getScale ());
56
61
}
57
62
58
63
@ ModifyConstant (method = "getChatComponent" , constant = @ Constant (intValue = 27 ))
@@ -62,14 +67,26 @@ private int mouseY(int constant) {
62
67
return height - (int ) (hud .position .getBottomY () - hud .getPaddingY () * hud .getScale () + ModCompatHooks .getChatPosition ());
63
68
}
64
69
70
+ @ ModifyVariable (method = "getChatComponent" , at = @ At ("STORE" ), ordinal = 0 )
71
+ private ChatLine capture (ChatLine chatLine ) {
72
+ currentLine = chatLine ;
73
+ return chatLine ;
74
+ }
75
+
76
+ @ ModifyConstant (method = "getChatComponent" , constant = @ Constant (intValue = 0 ))
77
+ private int offset (int value ) {
78
+ return ((ChatLineHook ) currentLine ).chatting$hasDetected () || ChattingConfig .INSTANCE .getOffsetNonPlayerMessages () ? ModCompatHooks .getChatHeadOffset () : 0 ;
79
+ }
80
+
65
81
@ Redirect (method = "getChatComponent" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/GuiNewChat;getChatScale()F" , ordinal = 0 ))
66
82
private float getScale (GuiNewChat instance ) {
67
83
return ChattingConfig .INSTANCE .getChatWindow ().getScale ();
68
84
}
69
85
70
- @ Redirect (method = "getChatComponent" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/GuiNewChat;getChatScale()F" , ordinal = 1 ))
71
- private float getScale2 (GuiNewChat instance ) {
72
- return 1f ;
86
+ @ ModifyArg (method = "getChatComponent" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/util/MathHelper;floor_float(F)I" , ordinal = 2 ))
87
+ private float width (float value ) {
88
+ ChatWindow hud = ChattingConfig .INSTANCE .getChatWindow ();
89
+ return hud .position .getX () + hud .getWidth ();
73
90
}
74
91
75
92
}
0 commit comments