Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit a56152c

Browse files
committed
fix chathud with scaling
1 parent f4040cb commit a56152c

File tree

1 file changed

+11
-13
lines changed
  • src/main/java/io/github/axolotlclient/modules/hud/gui/hud

1 file changed

+11
-13
lines changed

src/main/java/io/github/axolotlclient/modules/hud/gui/hud/ChatHud.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void render(){
5454
float f = this.client.options.chatOpacity * 0.9F + 0.1F;
5555
if (k > 0) {
5656

57-
float g = getChatScale();
57+
float g = getScale();
5858
int l = MathHelper.ceil((float)getWidth() / g);
5959
GlStateManager.pushMatrix();
6060

@@ -85,7 +85,7 @@ public void render(){
8585
}
8686

8787
if (isChatFocused()) {
88-
int m = this.client.textRenderer.fontHeight;
88+
int m = getFontHeight();
8989
GlStateManager.translatef(-3.0F, 0.0F, 0.0F);
9090
int r = k * m + k;
9191
int n = j * m + j;
@@ -107,17 +107,15 @@ public Text getTextAt(int x, int y){
107107

108108
List<ChatHudLine> visibleMessages = ((ChatHudAccessor) client.inGameHud.getChatHud()).getVisibleMessages();
109109

110-
int offsetOnHudX = x - getPos().x;
111-
int offsetOnHudY = - (y - (getPos().y +height));
112-
110+
int offsetOnHudX = MathHelper.floor(x/getScale() - getPos().x);
111+
int offsetOnHudY = MathHelper.floor(- (y/getScale() - (getPos().y +height)));
113112

114113
int scrolledLines = ((ChatHudAccessor) client.inGameHud.getChatHud()).getScrolledLines();
115114

116-
117115
if (offsetOnHudX >= 0 && offsetOnHudY >= 0) {
118116
int l = Math.min(this.getVisibleLineCount(), visibleMessages.size());
119-
if (offsetOnHudX <= MathHelper.floor((float)this.getWidth() / this.getChatScale()) && offsetOnHudY < (this.client.textRenderer.fontHeight + lineSpacing.get()) * l + l) {
120-
int m = offsetOnHudY / (this.client.textRenderer.fontHeight + lineSpacing.get()) + scrolledLines;
117+
if (offsetOnHudX <= MathHelper.floor((float)this.getWidth() / this.getScale()) && offsetOnHudY < (getFontHeight() + lineSpacing.get()) * l + l) {
118+
int m = offsetOnHudY / (getFontHeight() + lineSpacing.get()) + scrolledLines;
121119
if (m >= 0 && m < visibleMessages.size()) {
122120
ChatHudLine chatHudLine = visibleMessages.get(m);
123121
int n = 0;
@@ -211,10 +209,6 @@ public int getHeight() {
211209
return getHeight(this.isChatFocused() ? this.client.options.chatHeightFocused : this.client.options.chatHeightUnfocused);
212210
}
213211

214-
public float getChatScale() {
215-
return this.client.options.chatScale;
216-
}
217-
218212
public static int getWidth(float chatWidth) {
219213
int i = 320;
220214
int j = 40;
@@ -227,7 +221,11 @@ public static int getHeight(float chatHeight) {
227221
return MathHelper.floor(chatHeight * (float)(i - j) + (float)j);
228222
}
229223

224+
protected int getFontHeight(){
225+
return MathHelper.floor(MinecraftClient.getInstance().textRenderer.fontHeight);
226+
}
227+
230228
public int getVisibleLineCount() {
231-
return this.getHeight() / 9;// (9+lineSpacing.get());
229+
return this.getHeight() / 9;
232230
}
233231
}

0 commit comments

Comments
 (0)