Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift the entire chat instead of shifting different elements separately #141

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/main/java/obro1961/chatpatches/mixin/gui/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,16 @@ private int moreWidth(int defaultWidth) {
return config.chatWidth > 0 ? config.chatWidth : defaultWidth;
}


/**
* These methods shift various parts of the ChatHud by
* These methods shift the entire chat hud by
* {@link Config#shiftChat}, including the text, scroll
* bar, indicator bar, and hover text.
* They all shift the y value, with the name of the parameter
* corresponding to the (yarn mapped) target variable name.
* bar, hover text and indicator bar
* by shifting the y position of the chat.
*/
@ModifyVariable(method = "render", at = @At(value = "STORE", ordinal = 0), index = 31) // STORE ordinal=0 to not target all x stores
private int moveChatText(int x) {
return x - MathHelper.floor(config.shiftChat / this.getChatScale());
}
@ModifyVariable(method = "render", at = @At(value = "STORE", ordinal = 0), index = 27)
private int moveScrollBar(int af) {
return af + MathHelper.floor(config.shiftChat / this.getChatScale());
@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 7)
private int moveEntireChat(int y) {
return y - MathHelper.floor(config.shiftChat / this.getChatScale());
}
// condensed to one method because the first part of both methods are practically identical
@ModifyVariable(method = {"getIndicatorAt", "getTextStyleAt"}, argsOnly = true, at = @At("HEAD"), ordinal = 1)
Expand Down Expand Up @@ -318,4 +314,4 @@ private Text addCounter(Text incoming, boolean refreshing) {

return incoming;
}
}
}